home *** CD-ROM | disk | FTP | other *** search
/ Aminet 15 / Aminet 15 - Nov 1996.iso / Aminet / disk / cdrom / SkandalfoCDP.lha / SCDPlayer / Sources / scdp.c < prev    next >
C/C++ Source or Header  |  1996-09-07  |  164KB  |  3,803 lines

  1. #include "SCDP.h"
  2. #include "scdplogo.h"
  3.  
  4. /* In v1.5 I got fed of #including in SCDP.h (^: */
  5. #include <rexx/rxslib.h>
  6. #include <rexx/errors.h>
  7. #include <proto/rexxsyslib.h>
  8.  
  9. #include <libraries/asl.h>
  10. #include <proto/asl.h>
  11.  
  12. enum ReturnIDs
  13. {
  14.     ID_Play=1, ID_Pause, ID_Stop, ID_Previous, ID_Next, ID_Rewind, ID_FastForward, ID_Eject,
  15.     ID_Volume,ID_ProgramL,ID_Shuffle,ID_Repeat,
  16.     ID_TrackSelect,ID_ProgramSelect,ID_List,ID_ProgramR,
  17.     ID_Use,ID_Save,ID_RexxSave,ID_Confirm,ID_ChangeActive,ID_PUse,ID_PSave,ID_PRexxSave,ID_PInsert,
  18.     ID_A1,ID_A2,ID_A3,ID_A4,ID_A5,ID_A6,ID_A7,ID_A8,
  19.     /* For menus */
  20.     MEN_PROJECT,MEN_ABOUT,MEN_ABOUTMUI,MEN_QUIT,MEN_SETTINGS,MEN_MUI,
  21.     MEN_AREXX,MEN_EXECUTE,MEN_A1,MEN_A2,MEN_A3,MEN_A4,MEN_A5,MEN_A6,MEN_A7,MEN_A8
  22.  
  23. };
  24.  
  25. #define min(a,b) (((a)<(b))?(a):(b))
  26.  
  27. #define MyImageButton(image,key,help) ImageObject,MUIA_Background,MUII_ButtonBack, ButtonFrame, MUIA_Weight, 0, MUIA_Image_Spec,"4:PROGDIR:images/" image, /*MUIA_ControlChar, key,*/ MUIA_InputMode,MUIV_InputMode_RelVerify,MUIA_ShortHelp,glstr(help), End
  28. #define MyImageButtonNH(image,key) ImageObject,MUIA_Background,MUII_ButtonBack, ButtonFrame, MUIA_Weight, 0, MUIA_Image_Spec, image, MUIA_ControlChar, key, MUIA_InputMode,MUIV_InputMode_RelVerify, End
  29. #define MyImage(image) ImageObject, MUIA_Weight, 0, MUIA_Image_Spec,"4:PROGDIR:images/" image, End
  30. #define MyImageButton2(image,key,help) ImageObject, MUIA_Background,MUII_ButtonBack, ButtonFrame, MUIA_Weight, 0, MUIA_Image_Spec,"4:PROGDIR:images/" image, /*MUIA_ControlChar, key,*/ MUIA_InputMode,MUIV_InputMode_Toggle,MUIA_ShortHelp,glstr(help), End
  31.  
  32. #define max(a,b) ((a)>(b))?(a):(b)
  33. #define min(a,b) ((a)<(b))?(a):(b)
  34.  
  35. /* Function prototypes */
  36. int DoScsiCmd(UBYTE *data, int datasize, UBYTE *cmd, int cmdsize, UBYTE flags);
  37. void CDEject(void);
  38. void CDLoad(void);
  39. void CDStop(void);
  40. void CDGetPos(BOOL settimer);
  41. void CDSetVolume(int volume);
  42. void CDResume(void);
  43. void CDPause(void);
  44. void CDPlay(int start, int length);
  45. void CDReadContents(void);
  46. void DoShuffle(void);
  47. void DoProgram(void);
  48. void FillList(void);
  49.  
  50. /* Some global vars */
  51. enum status_enum {NODISK,STOPPED,PAUSED,PLAYING} status=NODISK;     /* CD status*/
  52. enum pstatus_enum {NORMAL,PROGRAM,SHUFFLE} pstatus=NORMAL;          /* Program status */
  53. UBYTE track=0;                                                      /* Track being played */
  54. ULONG actualindex=0;/* address in actualtrack */
  55. ULONG totalindex=0; /* address in CD */
  56. UBYTE validTOC=0;   /* 1=We have read a valid TOC, 0=No */
  57. UBYTE *TOCbuf=NULL;      /* Buffer for Table Of Contents */
  58. UBYTE TOClength;    /* Number of tracks */
  59. UBYTE TOCflags[100];/* 0=CDDA, 1=Data */
  60. ULONG TOCaddr[100]; /* Track starts */
  61. char TOCCDID[20];           /* Id string of CD */
  62. char TOCCDtitle[128];       /* Title of actual CD */
  63. char TOCCDartist[128];      /* Artist */
  64.  
  65. UBYTE programmed[101];  /* List of programmed/shuffled tracks */
  66. UBYTE pprog[101];      /* Definitely programmed tracks */
  67. UBYTE pactual;
  68.  
  69. BOOL refresh=FALSE;
  70. BOOL trayout=FALSE;     /* For Eject/Load */
  71. BOOL onevalid=FALSE;     /* Is there at least one CDDA track? */
  72.  
  73. BOOL userstop=TRUE; /* We want CDROM stopped */
  74. UBYTE actuate=0;
  75. UBYTE skip=3;       /* Kludge for waiting for a track's begin */
  76. UBYTE delayedplay=0;    /* Kludge for autoplay */
  77.  
  78. /* Global vars for timing */
  79. struct timerequest *tioreq=NULL;
  80. MSGPORT *tmsgport=NULL;
  81.  
  82. /* Global vars for SCSI control */
  83. IOSTDREQ *ioreq=NULL;
  84. MSGPORT *msgport=NULL;
  85. UBYTE *scsidata=NULL;
  86. SCSICMD *scsicmd=NULL;
  87. UBYTE *scsisense=NULL;
  88.  
  89. UBYTE scsidev[256]="scsi.device";
  90. int scsiid=4;
  91. BOOL volumecontrol=TRUE;
  92.  
  93. /* For the logo */
  94. static struct BitMap logobm=
  95. {
  96.     30,
  97.     30,
  98.     0,
  99.     2,
  100.     PAD,
  101.     (UBYTE *)logoplane0,
  102.     (UBYTE *)logoplane1,
  103.     NULL,NULL,NULL,NULL,NULL,NULL
  104. };
  105.  
  106. const ULONG logocolours[]=
  107. {
  108.     0xc0c0c0c0, 0xc0c0c0c0, 0xc0c0c0c0,
  109.     0x00000000, 0x00000000, 0x00000000,
  110.     0xffffffff, 0xffffffff, 0xffffffff,
  111.     0x46464646, 0x7c7c7c7c, 0xbbbbbbbb
  112. };
  113.  
  114. /* For the menu */
  115. static struct NewMenu menudata[]=
  116. {
  117.     { NM_TITLE, NULL,           0, 0, 0,    (APTR)MEN_PROJECT   },
  118.     { NM_ITEM,  NULL,           0, 0, 0,    (APTR)MEN_ABOUT     },
  119.     { NM_ITEM,  NULL,           0, 0, 0,    (APTR)MEN_ABOUTMUI  },
  120.     { NM_ITEM,  NM_BARLABEL,    0, 0, 0,    (APTR)0             },
  121.     { NM_ITEM,  NULL,           0, 0, 0,    (APTR)MEN_QUIT      },
  122.     { NM_TITLE, NULL,           0, 0, 0,    (APTR)MEN_SETTINGS  },
  123.     { NM_ITEM,  NULL,           0, 0, 0,    (APTR)MEN_MUI       },
  124.     { NM_TITLE, NULL,           0, 0, 0,    (APTR)MEN_AREXX     },
  125.     { NM_ITEM,  NULL,           0, 0, 0,    (APTR)MEN_EXECUTE   },
  126.     { NM_ITEM,  NM_BARLABEL,    0, 0, 0,    (APTR)0             },
  127.     { NM_ITEM, NULL,            0, 0, 0,    (APTR)MEN_A1        },
  128.     { NM_ITEM, NULL,            0, 0, 0,    (APTR)MEN_A2        },
  129.     { NM_ITEM, NULL,            0, 0, 0,    (APTR)MEN_A3        },
  130.     { NM_ITEM, NULL,            0, 0, 0,    (APTR)MEN_A4        },
  131.     { NM_ITEM, NULL,            0, 0, 0,    (APTR)MEN_A5        },
  132.     { NM_ITEM, NULL,            0, 0, 0,    (APTR)MEN_A6        },
  133.     { NM_ITEM, NULL,            0, 0, 0,    (APTR)MEN_A7        },
  134.     { NM_ITEM, NULL,            0, 0, 0,    (APTR)MEN_A8        },
  135.     { NM_END,NULL,0,0,0,(APTR)0 },
  136. };
  137.  
  138. static char *regtitles[3]={NULL,NULL,NULL};
  139.  
  140. static APTR AP_SCDP=NULL;
  141. static APTR WI_SCDP,WI_List,WI_Program;
  142. static APTR TX_Track,TX_TitleTime,TX_CDTime,TX_Artist,TX_Title;
  143. static APTR BT_Play,BT_Pause,BT_Stop,BT_Previous,BT_Next,BT_Rewind,BT_FastForward,BT_Eject,BT_Shuffle,BT_ProgramL,BT_Repeat;
  144. static APTR BT_ProgramR,BT_List;
  145. static APTR SL_Volume;
  146. static APTR ST_Artist,ST_CDTitle,ST_Title,RG_RegTraPro,LV_TrackSelect,LV_ProgramSelect,LV_TitleList,BT_Use,BT_Save,BT_Cancel;
  147. static APTR LV_PList,LI_PList,LV_Program,BT_PUse,BT_PSave,BT_PCancel,BT_PNew,BT_PDelete,BT_PUp,BT_PDown,BT_PTop,BT_PBottom;
  148. static APTR MN_Menu, WI_AboutMUI=NULL;
  149. static APTR BT_A[8];
  150. /* New for V1.3 */
  151.  
  152. static APTR CH_AutoPlay,CH_AutoProgram,CH_AutoShuffle,CH_AutoRepeat;
  153.  
  154. struct TextFont *getfont(char *name)
  155. {
  156.     char buff[100];
  157.     int i;
  158.     struct TextAttr ta;
  159.  
  160.     i=0;
  161.     while((buff[i]=name[i])!='/' && buff[i]!='\0')
  162.         i++;
  163.  
  164.     if(!buff[i])
  165.         return NULL;
  166.  
  167.     buff[i]='\0';
  168.     strcat(buff,".font");
  169.  
  170.     ta.ta_Name=buff;
  171.     ta.ta_YSize=atoi(name+i+1);
  172.     ta.ta_Style=0;
  173.     ta.ta_Flags=0;
  174.  
  175.     return OpenDiskFont(&ta);
  176. }
  177.  
  178. /* I will try here to program some drag&drop for program window */
  179. /* See DragnDrop.c in MUI examples */
  180. struct ProgramList_Data
  181. {
  182.     LONG dummy;
  183. };
  184.  
  185. ULONG ProgramList_DragQuery(struct IClass *cl, Object *obj, struct MUIP_DragDrop *msg)
  186. {
  187.     if(msg->obj==obj)
  188.         return(DoSuperMethodA(cl,obj,msg));
  189.     else if(msg->obj==(Object *)LI_PList) /* Hard coded source list */
  190.         return(MUIV_DragQuery_Accept);
  191.     else
  192.         return(MUIV_DragQuery_Refuse);
  193. }
  194.  
  195. ULONG ProgramList_DragDrop(struct IClass *cl, Object *obj, struct MUIP_DragDrop *msg)
  196. {
  197.     if(msg->obj==obj)
  198.         return(DoSuperMethodA(cl,obj,msg));
  199.     else
  200.     {
  201.         char *entry;
  202.         LONG dropmark;
  203.  
  204.         DoMethod(msg->obj,MUIM_List_GetEntry,MUIV_List_GetEntry_Active,&entry);
  205.  
  206.         get(obj,MUIA_List_DropMark,&dropmark);
  207.         DoMethod(obj,MUIM_List_InsertSingle,entry,dropmark);
  208.  
  209.         get(obj,MUIA_List_InsertPosition,&dropmark);
  210.         set(obj,MUIA_List_Active,dropmark);
  211.         set(msg->obj,MUIA_List_Active,MUIV_List_Active_Off);
  212.  
  213.         return 0;
  214.     }
  215. }
  216.  
  217. SAVEDS ASM ULONG ProgramList_Dispatcher(REG(a0) struct IClass *cl,REG(a2) Object *obj,REG(a1) Msg msg)
  218. {
  219.     switch(msg->MethodID)
  220.     {
  221.         case MUIM_DragQuery:    return ProgramList_DragQuery(cl,obj,(APTR)msg);
  222.         case MUIM_DragDrop:     return ProgramList_DragDrop(cl,obj,(APTR)msg);
  223.     }
  224.     return DoSuperMethodA(cl,obj,msg);
  225. }
  226.  
  227. /* New for V1.4 */
  228. char hotkeys[12][128]=
  229. {
  230.     "control lcommand space",       /* Play */
  231.     "control lcommand z",           /* Pause */
  232.     "control lcommand x",           /* Stop */
  233.     "control lcommand <",           /* Previous */
  234.     "control lcommand >",           /* Next */
  235.     "control lcommand c",           /* Rewind */
  236.     "control lcommand v",           /* Fast forward */
  237.     "control lcommand `",           /* Eject/load */
  238.     "control lcommand p",           /* Program mode */
  239.     "control lcommand s",           /* Shuffle mode */
  240.     "control lcommand r",           /* Repeat mode */
  241.     "control lcommand numericpad enter"        /* CX_POPKEY */
  242. };
  243.  
  244. CxObj *filter[12],*sender[12],*translate[12];
  245.  
  246. SAVEDS ASM void brokerfunction(REG(a0) struct Hook *hook, REG(a2) APTR app, REG(a1) CxMsg *msg)
  247. {
  248.     ULONG msgid,msgtype;
  249.     LONG flag;
  250.  
  251.     msgtype=CxMsgType(msg);
  252.     if(msgtype==CXM_IEVENT)
  253.     {
  254.         msgid=CxMsgID(msg);
  255.         switch(msgid)
  256.         {
  257.             case 0:
  258.                 DoMethod(AP_SCDP,MUIM_Application_ReturnID,ID_Play);
  259.                 break;
  260.             case 1:
  261.                 DoMethod(AP_SCDP,MUIM_Application_ReturnID,ID_Pause);
  262.                 break;
  263.             case 2:
  264.                 DoMethod(AP_SCDP,MUIM_Application_ReturnID,ID_Stop);
  265.                 break;
  266.             case 3:
  267.                 DoMethod(AP_SCDP,MUIM_Application_ReturnID,ID_Previous);
  268.                 break;
  269.             case 4:
  270.                 DoMethod(AP_SCDP,MUIM_Application_ReturnID,ID_Next);
  271.                 break;
  272.             case 5:
  273.                 DoMethod(AP_SCDP,MUIM_Application_ReturnID,ID_Rewind);
  274.                 break;
  275.             case 6:
  276.                 DoMethod(AP_SCDP,MUIM_Application_ReturnID,ID_FastForward);
  277.                 break;
  278.             case 7:
  279.                 DoMethod(AP_SCDP,MUIM_Application_ReturnID,ID_Eject);
  280.                 break;
  281.             case 8:
  282.                 get(BT_ProgramL,MUIA_Selected,&flag);
  283.                 flag^=TRUE;
  284.                 set(BT_ProgramL,MUIA_Selected,flag);
  285.                 break;
  286.             case 9:
  287.                 get(BT_Shuffle,MUIA_Selected,&flag);
  288.                 flag^=TRUE;
  289.                 set(BT_Shuffle,MUIA_Selected,flag);
  290.                 break;
  291.             case 10:
  292.                 get(BT_Repeat,MUIA_Selected,&flag);
  293.                 flag^=TRUE;
  294.                 set(BT_Repeat,MUIA_Selected,flag);
  295.                 break;
  296.             case 11:
  297.                 get(AP_SCDP,MUIA_Application_Iconified,&flag);
  298.                 flag^=TRUE;
  299.                 set(AP_SCDP,MUIA_Application_Iconified,flag);
  300.                 break;
  301.         }
  302.     }
  303. }
  304.  
  305. static const struct Hook brokerhook=
  306. {
  307.     {
  308.         NULL,NULL
  309.     },
  310.     brokerfunction,
  311.     NULL,
  312.     NULL
  313. };
  314.  
  315. int MakeCxObj( CxObj *broker, struct MsgPort *BrokerMP, int nr, char *FiltStr )
  316. {
  317. if (filter[nr] = CxFilter( FiltStr ))
  318.     {
  319.     AttachCxObj(broker, filter[nr]);
  320.     if (sender[nr] = CxSender(BrokerMP, (LONG)nr))
  321.         {
  322.         AttachCxObj(filter[nr], sender[nr] );
  323.         if (translate[nr] = CxTranslate(NULL))
  324.             {
  325.             AttachCxObj(filter[nr], translate[nr]);
  326.             return( CxObjError( filter[nr] ) );
  327.             }
  328.         }
  329.     }
  330. return( 1 );
  331. }
  332.  
  333. void SetUpHotKeys(void)
  334. {
  335.     CxObj *broker;
  336.     struct MsgPort *brokerport;
  337.     int i;
  338.  
  339.     get(AP_SCDP,MUIA_Application_Broker,&broker);
  340.     get(AP_SCDP,MUIA_Application_BrokerPort,&brokerport);
  341.  
  342.     if(!broker || !brokerport)
  343.         return;
  344.  
  345.     for(i=0;i<12;i++)
  346.     {
  347.         MakeCxObj(broker, brokerport, i, hotkeys[i]);
  348.     }
  349. }
  350.  
  351. int popupflag=-1;
  352.  
  353. /* NEW FOR v1.5 ARexx port! */
  354.  
  355. int useraction=0;
  356. BOOL quitting=FALSE;
  357.  
  358. SAVEDS ASM LONG playrawfunction(REG(a0) struct Hook *hook, REG(a2) APTR app, REG(a1) LONG *args)
  359. {
  360.     LONG a,b;
  361.  
  362.     if(status==NODISK)
  363.         return 5;
  364.     
  365.     useraction=-1;
  366.     
  367.     pstatus=NORMAL;
  368.     set(BT_Shuffle,MUIA_Selected,FALSE);
  369.     set(BT_ProgramL,MUIA_Selected,FALSE);
  370.     set(BT_Repeat,MUIA_Selected,FALSE);
  371.     
  372.     a=*((LONG *)args[0]);
  373.     if(args[1])
  374.     {
  375.         b=*((LONG *)args[1]);
  376.     }
  377.     else
  378.     {
  379.         b=TOCaddr[TOClength];
  380.     }
  381.     
  382.     CDPlay(a,b-a);
  383.     
  384.     actuate=0;
  385.     skip=2;
  386.     
  387.     return 0;
  388. }
  389.  
  390. static const struct Hook playrawhook=
  391. {
  392.     {
  393.         NULL,NULL
  394.     },
  395.     playrawfunction,
  396.     NULL,
  397.     NULL
  398. };
  399.  
  400. SAVEDS ASM LONG playtrackfunction(REG(a0) struct Hook *hook, REG(a2) APTR app, REG(a1) LONG *args)
  401. {
  402.     LONG a;
  403.  
  404.     if(status==NODISK)
  405.         return 5;
  406.     
  407.     useraction=-1;
  408.     
  409.     pstatus=NORMAL;
  410.     set(BT_Shuffle,MUIA_Selected,FALSE);
  411.     set(BT_ProgramL,MUIA_Selected,FALSE);
  412.     set(BT_Repeat,MUIA_Selected,FALSE);
  413.  
  414.     a=*((LONG *)args[0]);
  415.     
  416.     if(a<1 || a>TOClength || TOCflags[a-1])
  417.         return 5;
  418.     
  419.     CDPlay(TOCaddr[a-1],TOCaddr[a]-TOCaddr[a-1]);
  420.     
  421.     actuate=0;
  422.     skip=2;
  423.     
  424.     return 0;
  425. }
  426.  
  427. static const struct Hook playtrackhook=
  428. {
  429.     {
  430.         NULL,NULL
  431.     },
  432.     playtrackfunction,
  433.     NULL,
  434.     NULL
  435. };
  436.  
  437. SAVEDS ASM LONG playingposfunction(REG(a0) struct Hook *hook, REG(a2) APTR app, REG(a1) LONG *args)
  438. {
  439.     char buff[20];
  440.  
  441.     if(status==NODISK || status==STOPPED)
  442.     {
  443.         set(AP_SCDP,MUIA_Application_RexxString,"-1");
  444.         return 5;
  445.     }
  446.     
  447.     useraction=0;
  448.     
  449.     CDGetPos(FALSE);
  450.     
  451.     sprintf(buff,"%d",totalindex);
  452.     set(AP_SCDP,MUIA_Application_RexxString,buff);
  453.     
  454.     return 0;
  455. }
  456.  
  457. static const struct Hook playingposhook=
  458. {
  459.     {
  460.         NULL,NULL
  461.     },
  462.     playingposfunction,
  463.     NULL,
  464.     NULL
  465. };
  466.  
  467. SAVEDS ASM LONG playingtrackfunction(REG(a0) struct Hook *hook, REG(a2) APTR app, REG(a1) LONG *args)
  468. {
  469.     char buff[20];
  470.  
  471.     if(status==NODISK || status==STOPPED)
  472.     {
  473.         set(AP_SCDP,MUIA_Application_RexxString,"-1");
  474.         return 5;
  475.     }
  476.     
  477.     useraction=0;
  478.     
  479.     CDGetPos(FALSE);
  480.     
  481.     sprintf(buff,"%d",track);
  482.     set(AP_SCDP,MUIA_Application_RexxString,buff);
  483.     
  484.     return 0;
  485. }
  486.  
  487. static const struct Hook playingtrackhook=
  488. {
  489.     {
  490.         NULL,NULL
  491.     },
  492.     playingtrackfunction,
  493.     NULL,
  494.     NULL
  495. };
  496.  
  497. SAVEDS ASM LONG setprogramfunction(REG(a0) struct Hook *hook, REG(a2) APTR app, REG(a1) LONG *args)
  498. {
  499.     LONG **q;
  500.     int a;
  501.     char *strptr;
  502.  
  503.     if(status==NODISK)
  504.     {
  505.         set(AP_SCDP,MUIA_Application_RexxString,"-1");
  506.         return 5;
  507.     }
  508.     
  509.     useraction=0;
  510.     
  511.     set(WI_Program,MUIA_Window_Open,FALSE);
  512.     
  513.     if(pstatus==PROGRAM && status==PLAYING)
  514.     {
  515.         CDStop();
  516.     }   
  517.     
  518.     q=(LONG **)args[0];
  519.     
  520.     if(!q)
  521.     {
  522.         pprog[0]=0;
  523.         if(pstatus==PROGRAM)
  524.         {
  525.             DoProgram();
  526.         }       
  527.  
  528.         DoMethod(LV_ProgramSelect,MUIM_List_Clear);
  529.  
  530.         return 0;
  531.     }
  532.  
  533.     a=0;
  534.     while(q[a])
  535.     {
  536.         if(*(q[a])<1 || *(q[a])>TOClength)
  537.             return 5;
  538.         a++;
  539.     }
  540.     
  541.     a=0;
  542.     while(q[a])
  543.     {
  544.         pprog[a]=*(q[a]);
  545.         a++;
  546.     }
  547.     pprog[a]=0;
  548.     
  549.     if(pstatus==PROGRAM)
  550.     {
  551.         DoProgram();
  552.     }
  553.  
  554.     set(LV_ProgramSelect,MUIA_List_Quiet,TRUE);
  555.     DoMethod(LV_ProgramSelect,MUIM_List_Clear);
  556.     a=0;
  557.     while(pprog[a])
  558.     {
  559.         DoMethod(LV_TrackSelect,MUIM_List_GetEntry,pprog[a]-1,&strptr);
  560.         DoMethod(LV_ProgramSelect,MUIM_List_InsertSingle,strptr,MUIV_List_Insert_Bottom);
  561.         a++;
  562.     }
  563.     set(LV_ProgramSelect,MUIA_List_Quiet,FALSE);
  564.     
  565.     return 0;
  566. }
  567.  
  568. static const struct Hook setprogramhook=
  569. {
  570.     {
  571.         NULL,NULL
  572.     },
  573.     setprogramfunction,
  574.     NULL,
  575.     NULL
  576. };
  577.  
  578. SAVEDS ASM LONG programfunction(REG(a0) struct Hook *hook, REG(a2) APTR app, REG(a1) LONG *args)
  579. {
  580.     int a;
  581.     char buff[10];
  582.  
  583.     if(status==NODISK)
  584.     {
  585.         set(AP_SCDP,MUIA_Application_RexxString,"-1");
  586.         return 5;
  587.     }
  588.     
  589.     useraction=-1;
  590.     
  591.     if(args[0])
  592.     {
  593.         a=*((LONG *)args[0]);
  594.         if(a)
  595.             a=1;
  596.         set(BT_ProgramL,MUIA_Selected,a);
  597.     }
  598.     
  599.     get(BT_ProgramL,MUIA_Selected,&a);
  600.     
  601.     sprintf(buff,"%d",a);
  602.     set(AP_SCDP,MUIA_Application_RexxString,buff);
  603.     
  604.     return 0;
  605. }
  606.  
  607. static const struct Hook programhook=
  608. {
  609.     {
  610.         NULL,NULL
  611.     },
  612.     programfunction,
  613.     NULL,
  614.     NULL
  615. };
  616.  
  617. SAVEDS ASM LONG shufflefunction(REG(a0) struct Hook *hook, REG(a2) APTR app, REG(a1) LONG *args)
  618. {
  619.     int a;
  620.     char buff[10];
  621.  
  622.     if(status==NODISK)
  623.     {
  624.         set(AP_SCDP,MUIA_Application_RexxString,"-1");
  625.         return 5;
  626.     }
  627.     
  628.     useraction=-1;
  629.     
  630.     if(args[0])
  631.     {
  632.         a=*((LONG *)args[0]);
  633.         if(a)
  634.             a=1;
  635.         set(BT_Shuffle,MUIA_Selected,a);
  636.     }
  637.     
  638.     get(BT_Shuffle,MUIA_Selected,&a);
  639.     
  640.     sprintf(buff,"%d",a);
  641.     set(AP_SCDP,MUIA_Application_RexxString,buff);
  642.     
  643.     return 0;
  644. }
  645.  
  646. static const struct Hook shufflehook=
  647. {
  648.     {
  649.         NULL,NULL
  650.     },
  651.     shufflefunction,
  652.     NULL,
  653.     NULL
  654. };
  655.  
  656. SAVEDS ASM LONG repeatfunction(REG(a0) struct Hook *hook, REG(a2) APTR app, REG(a1) LONG *args)
  657. {
  658.     int a;
  659.     char buff[10];
  660.  
  661.     if(status==NODISK)
  662.     {
  663.         set(AP_SCDP,MUIA_Application_RexxString,"-1");
  664.         return 5;
  665.     }
  666.     
  667.     useraction=0;
  668.     
  669.     if(args[0])
  670.     {
  671.         a=*((LONG *)args[0]);
  672.         if(a)
  673.             a=1;
  674.         set(BT_Repeat,MUIA_Selected,a);
  675.     }
  676.     
  677.     get(BT_Repeat,MUIA_Selected,&a);
  678.     
  679.     sprintf(buff,"%d",a);
  680.     set(AP_SCDP,MUIA_Application_RexxString,buff);
  681.     
  682.     return 0;
  683. }
  684.  
  685. static const struct Hook repeathook=
  686. {
  687.     {
  688.         NULL,NULL
  689.     },
  690.     repeatfunction,
  691.     NULL,
  692.     NULL
  693. };
  694.  
  695. SAVEDS ASM LONG autoprogramfunction(REG(a0) struct Hook *hook, REG(a2) APTR app, REG(a1) LONG *args)
  696. {
  697.     int a;
  698.     char buff[10];
  699.  
  700.     if(status==NODISK)
  701.     {
  702.         set(AP_SCDP,MUIA_Application_RexxString,"-1");
  703.         return 5;
  704.     }
  705.     
  706.     useraction=0;
  707.     
  708.     if(args[0])
  709.     {
  710.         a=*((LONG *)args[0]);
  711.         if(a)
  712.             a=1;
  713.         set(CH_AutoProgram,MUIA_Selected,a);
  714.     }
  715.     
  716.     get(CH_AutoProgram,MUIA_Selected,&a);
  717.     
  718.     sprintf(buff,"%d",a);
  719.     set(AP_SCDP,MUIA_Application_RexxString,buff);
  720.     
  721.     return 0;
  722. }
  723.  
  724. static const struct Hook autoprogramhook=
  725. {
  726.     {
  727.         NULL,NULL
  728.     },
  729.     autoprogramfunction,
  730.     NULL,
  731.     NULL
  732. };
  733.  
  734. SAVEDS ASM LONG autoshufflefunction(REG(a0) struct Hook *hook, REG(a2) APTR app, REG(a1) LONG *args)
  735. {
  736.     int a;
  737.     char buff[10];
  738.  
  739.     if(status==NODISK)
  740.     {
  741.         set(AP_SCDP,MUIA_Application_RexxString,"-1");
  742.         return 5;
  743.     }
  744.     
  745.     useraction=0;
  746.     
  747.     if(args[0])
  748.     {
  749.         a=*((LONG *)args[0]);
  750.         if(a)
  751.             a=1;
  752.         set(CH_AutoShuffle,MUIA_Selected,a);
  753.     }
  754.     
  755.     get(CH_AutoShuffle,MUIA_Selected,&a);
  756.     
  757.     sprintf(buff,"%d",a);
  758.     set(AP_SCDP,MUIA_Application_RexxString,buff);
  759.     
  760.     return 0;
  761. }
  762.  
  763. static const struct Hook autoshufflehook=
  764. {
  765.     {
  766.         NULL,NULL
  767.     },
  768.     autoshufflefunction,
  769.     NULL,
  770.     NULL
  771. };
  772.  
  773. SAVEDS ASM LONG autorepeatfunction(REG(a0) struct Hook *hook, REG(a2) APTR app, REG(a1) LONG *args)
  774. {
  775.     int a;
  776.     char buff[10];
  777.  
  778.     if(status==NODISK)
  779.     {
  780.         set(AP_SCDP,MUIA_Application_RexxString,"-1");
  781.         return 5;
  782.     }
  783.     
  784.     useraction=0;
  785.     
  786.     if(args[0])
  787.     {
  788.         a=*((LONG *)args[0]);
  789.         if(a)
  790.             a=1;
  791.         set(CH_AutoRepeat,MUIA_Selected,a);
  792.     }
  793.     
  794.     get(CH_AutoRepeat,MUIA_Selected,&a);
  795.     
  796.     sprintf(buff,"%d",a);
  797.     set(AP_SCDP,MUIA_Application_RexxString,buff);
  798.     
  799.     return 0;
  800. }
  801.  
  802. static const struct Hook autorepeathook=
  803. {
  804.     {
  805.         NULL,NULL
  806.     },
  807.     autorepeatfunction,
  808.     NULL,
  809.     NULL
  810. };
  811.  
  812. SAVEDS ASM LONG autoplayfunction(REG(a0) struct Hook *hook, REG(a2) APTR app, REG(a1) LONG *args)
  813. {
  814.     int a;
  815.     char buff[10];
  816.  
  817.     if(status==NODISK)
  818.     {
  819.         set(AP_SCDP,MUIA_Application_RexxString,"-1");
  820.         return 5;
  821.     }
  822.     
  823.     useraction=0;
  824.     
  825.     if(args[0])
  826.     {
  827.         a=*((LONG *)args[0]);
  828.         if(a)
  829.             a=1;
  830.         set(CH_AutoPlay,MUIA_Selected,a);
  831.     }
  832.     
  833.     get(CH_AutoPlay,MUIA_Selected,&a);
  834.     
  835.     sprintf(buff,"%d",a);
  836.     set(AP_SCDP,MUIA_Application_RexxString,buff);
  837.     
  838.     return 0;
  839. }
  840.  
  841. static const struct Hook autoplayhook=
  842. {
  843.     {
  844.         NULL,NULL
  845.     },
  846.     autoplayfunction,
  847.     NULL,
  848.     NULL
  849. };
  850.  
  851. SAVEDS ASM LONG programmedtracksfunction(REG(a0) struct Hook *hook, REG(a2) APTR app, REG(a1) LONG *args)
  852. {
  853.     int a;
  854.     char buff[10];
  855.     
  856.     if(status==NODISK)
  857.     {
  858.         set(AP_SCDP,MUIA_Application_RexxString,"-1");
  859.         return 5;
  860.     }
  861.     
  862.     useraction=0;
  863.     
  864.     a=0;
  865.     while(pprog[a])
  866.         a++;
  867.     
  868.     sprintf(buff,"%d",a);
  869.     set(AP_SCDP,MUIA_Application_RexxString,buff);
  870.     
  871.     return 0;
  872. }
  873.  
  874. static const struct Hook programmedtrackshook=
  875. {
  876.     {
  877.         NULL,NULL
  878.     },
  879.     programmedtracksfunction,
  880.     NULL,
  881.     NULL
  882. };
  883.  
  884. SAVEDS ASM LONG programmedtrackfunction(REG(a0) struct Hook *hook, REG(a2) APTR app, REG(a1) LONG *args)
  885. {
  886.     int a,b;
  887.     char buff[10];
  888.     char *strptr;
  889.     
  890.     if(!args[0])
  891.     {
  892.         if(pstatus!=PROGRAM || status!=PLAYING)
  893.         {
  894.             set(AP_SCDP,MUIA_Application_RexxString,"-1");
  895.             return 5;
  896.         }
  897.         sprintf(buff,"%d",pactual);
  898.         set(AP_SCDP,MUIA_Application_RexxString,buff);
  899.     
  900.         useraction=0;
  901.     
  902.         return 0;
  903.     }
  904.     
  905.     if(status==NODISK)
  906.     {
  907.         set(AP_SCDP,MUIA_Application_RexxString,"-1");
  908.         return 5;
  909.     }
  910.     
  911.     set(WI_Program,MUIA_Window_Open,FALSE);
  912.     
  913.     b=*((LONG *)args[0]);
  914.     a=0;
  915.     while(pprog[a])
  916.         a++;
  917.     
  918.     if(b<1 || b>a)
  919.         return 5;
  920.     
  921.     useraction=0;
  922.         
  923.     if(args[1])
  924.     {
  925.         a=*((LONG *)args[1]);
  926.         
  927.         pprog[b-1]=a;
  928.         if(pstatus==PROGRAM && status==PLAYING)
  929.         {
  930.             CDStop();
  931.         }
  932.         if(pstatus==PROGRAM)
  933.         {
  934.             DoProgram();
  935.         }       
  936.     }
  937.     
  938.     sprintf(buff,"%d",pprog[b]);
  939.     set(AP_SCDP,MUIA_Application_RexxString,buff);
  940.  
  941.     set(LV_ProgramSelect,MUIA_List_Quiet,TRUE);
  942.     DoMethod(LV_ProgramSelect,MUIM_List_Clear);
  943.     a=0;
  944.     while(pprog[a])
  945.     {
  946.         DoMethod(LV_TrackSelect,MUIM_List_GetEntry,pprog[a]-1,&strptr);
  947.         DoMethod(LV_ProgramSelect,MUIM_List_InsertSingle,strptr,MUIV_List_Insert_Bottom);
  948.         a++;
  949.     }
  950.     set(LV_ProgramSelect,MUIA_List_Quiet,FALSE);
  951.     
  952.     return 0;
  953. }
  954.  
  955. static const struct Hook programmedtrackhook=
  956. {
  957.     {
  958.         NULL,NULL
  959.     },
  960.     programmedtrackfunction,
  961.     NULL,
  962.     NULL
  963. };
  964.  
  965. SAVEDS ASM LONG addprogrammedtrackfunction(REG(a0) struct Hook *hook, REG(a2) APTR app, REG(a1) LONG *args)
  966. {
  967.     int a,b;
  968.     char *strptr;
  969.  
  970.     if(status==NODISK)
  971.     {
  972.         return 5;
  973.     }
  974.     
  975.     useraction=0;
  976.     
  977.     set(WI_Program,MUIA_Window_Open,FALSE);
  978.     
  979.     b=*((LONG *)args[0]);
  980.     a=0;
  981.     while(pprog[a])
  982.         a++;
  983.     
  984.     pprog[a++]=b;
  985.     pprog[a]=0;
  986.     if(pstatus==PROGRAM && status==PLAYING)
  987.     {
  988.         CDStop();
  989.     }
  990.     if(pstatus==PROGRAM)
  991.     {
  992.         DoProgram();
  993.     }       
  994.  
  995.     set(LV_ProgramSelect,MUIA_List_Quiet,TRUE);
  996.     DoMethod(LV_ProgramSelect,MUIM_List_Clear);
  997.     a=0;
  998.     while(pprog[a])
  999.     {
  1000.         DoMethod(LV_TrackSelect,MUIM_List_GetEntry,pprog[a]-1,&strptr);
  1001.         DoMethod(LV_ProgramSelect,MUIM_List_InsertSingle,strptr,MUIV_List_Insert_Bottom);
  1002.         a++;
  1003.     }
  1004.     set(LV_ProgramSelect,MUIA_List_Quiet,FALSE);
  1005.     
  1006.     return 0;
  1007. }
  1008.  
  1009. static const struct Hook addprogrammedtrackhook=
  1010. {
  1011.     {
  1012.         NULL,NULL
  1013.     },
  1014.     addprogrammedtrackfunction,
  1015.     NULL,
  1016.     NULL
  1017. };
  1018.  
  1019. SAVEDS ASM LONG cdtitlefunction(REG(a0) struct Hook *hook, REG(a2) APTR app, REG(a1) LONG *args)
  1020. {
  1021.     if(status==NODISK)
  1022.         return 5;
  1023.     
  1024.     useraction=0;
  1025.     
  1026.     if(args[0])
  1027.     {
  1028.         set(WI_List,MUIA_Window_Open,FALSE);
  1029.         strcpy(TOCCDtitle,(char *)args[0]);
  1030.         refresh=TRUE;
  1031.     }   
  1032.  
  1033.     set(AP_SCDP,MUIA_Application_RexxString,TOCCDtitle);
  1034.  
  1035.     return 0;
  1036. }
  1037.  
  1038. static const struct Hook cdtitlehook=
  1039. {
  1040.     {
  1041.         NULL,NULL
  1042.     },
  1043.     cdtitlefunction,
  1044.     NULL,
  1045.     NULL
  1046. };
  1047.  
  1048. SAVEDS ASM LONG cdartistfunction(REG(a0) struct Hook *hook, REG(a2) APTR app, REG(a1) LONG *args)
  1049. {
  1050.     if(status==NODISK)
  1051.         return 5;
  1052.     
  1053.     useraction=0;
  1054.     
  1055.     if(args[0])
  1056.     {
  1057.         set(WI_List,MUIA_Window_Open,FALSE);
  1058.         strcpy(TOCCDartist,(char *)args[0]);
  1059.         refresh=TRUE;
  1060.     }   
  1061.  
  1062.     set(AP_SCDP,MUIA_Application_RexxString,TOCCDartist);
  1063.  
  1064.     return 0;
  1065. }
  1066.  
  1067. static const struct Hook cdartisthook=
  1068. {
  1069.     {
  1070.         NULL,NULL
  1071.     },
  1072.     cdartistfunction,
  1073.     NULL,
  1074.     NULL
  1075. };
  1076.  
  1077. SAVEDS ASM LONG cdtracksfunction(REG(a0) struct Hook *hook, REG(a2) APTR app, REG(a1) LONG *args)
  1078. {
  1079.     char buff[8];
  1080.     
  1081.     if(status==NODISK)
  1082.     {
  1083.         set(AP_SCDP,MUIA_Application_RexxString,"-1");
  1084.         return 5;
  1085.     }
  1086.     
  1087.     useraction=0;
  1088.     
  1089.     sprintf(buff,"%d",TOClength);
  1090.     set(AP_SCDP,MUIA_Application_RexxString,buff);
  1091.  
  1092.     return 0;
  1093. }
  1094.  
  1095. static const struct Hook cdtrackshook=
  1096. {
  1097.     {
  1098.         NULL,NULL
  1099.     },
  1100.     cdtracksfunction,
  1101.     NULL,
  1102.     NULL
  1103. };
  1104.  
  1105. SAVEDS ASM LONG tracknamefunction(REG(a0) struct Hook *hook, REG(a2) APTR app, REG(a1) LONG *args)
  1106. {
  1107.     char *strptr;
  1108.     char buff[256];
  1109.     int a;
  1110.     
  1111.     if(status==NODISK)
  1112.     {
  1113.         return 5;
  1114.     }
  1115.     
  1116.     a=*((LONG *)args[0]);
  1117.     
  1118.     if(a<1 || a>TOClength)
  1119.         return 5;
  1120.     
  1121.     useraction=0;
  1122.     
  1123.     if(args[1])
  1124.     {
  1125.         DoMethod(LV_TrackSelect,MUIM_List_Remove,a-1);
  1126.         sprintf(buff,"%02d: %s",a,(char *)args[1]);
  1127.         DoMethod(LV_TrackSelect,MUIM_List_InsertSingle,buff,a-1);
  1128.         refresh=TRUE;
  1129.     }   
  1130.     
  1131.     DoMethod(LV_TrackSelect,MUIM_List_GetEntry,a-1,&strptr);
  1132.     set(AP_SCDP,MUIA_Application_RexxString,strptr+4);
  1133.  
  1134.     return 0;
  1135. }
  1136.  
  1137. static const struct Hook tracknamehook=
  1138. {
  1139.     {
  1140.         NULL,NULL
  1141.     },
  1142.     tracknamefunction,
  1143.     NULL,
  1144.     NULL
  1145. };
  1146.  
  1147. SAVEDS ASM LONG trackstartfunction(REG(a0) struct Hook *hook, REG(a2) APTR app, REG(a1) LONG *args)
  1148. {
  1149.     char buff[16];
  1150.     int a;
  1151.     
  1152.     if(status==NODISK)
  1153.     {
  1154.         set(AP_SCDP,MUIA_Application_RexxString,"-1");
  1155.         return 5;
  1156.     }
  1157.     
  1158.     a=*((LONG *)args[0]);
  1159.     
  1160.     if(a<1 || a>TOClength)
  1161.     {
  1162.         set(AP_SCDP,MUIA_Application_RexxString,"-1");
  1163.         return 5;
  1164.     }
  1165.     
  1166.     useraction=0;
  1167.     
  1168.     sprintf(buff,"%d",TOCaddr[a-1]);
  1169.     set(AP_SCDP,MUIA_Application_RexxString,buff);
  1170.  
  1171.     return 0;
  1172. }
  1173.  
  1174. static const struct Hook trackstarthook=
  1175. {
  1176.     {
  1177.         NULL,NULL
  1178.     },
  1179.     trackstartfunction,
  1180.     NULL,
  1181.     NULL
  1182. };
  1183.  
  1184. SAVEDS ASM LONG trackendfunction(REG(a0) struct Hook *hook, REG(a2) APTR app, REG(a1) LONG *args)
  1185. {
  1186.     char buff[16];
  1187.     int a;
  1188.     
  1189.     if(status==NODISK)
  1190.     {
  1191.         set(AP_SCDP,MUIA_Application_RexxString,"-1");
  1192.         return 5;
  1193.     }
  1194.     
  1195.     a=*((LONG *)args[0]);
  1196.     
  1197.     if(a<1 || a>TOClength)
  1198.     {
  1199.         set(AP_SCDP,MUIA_Application_RexxString,"-1");
  1200.         return 5;
  1201.     }
  1202.     
  1203.     useraction=0;
  1204.     
  1205.     sprintf(buff,"%d",TOCaddr[a]);
  1206.     set(AP_SCDP,MUIA_Application_RexxString,buff);
  1207.  
  1208.     return 0;
  1209. }
  1210.  
  1211. static const struct Hook trackendhook=
  1212. {
  1213.     {
  1214.         NULL,NULL
  1215.     },
  1216.     trackendfunction,
  1217.     NULL,
  1218.     NULL
  1219. };
  1220.  
  1221. SAVEDS ASM LONG isdatatrackfunction(REG(a0) struct Hook *hook, REG(a2) APTR app, REG(a1) LONG *args)
  1222. {
  1223.     char buff[16];
  1224.     int a;
  1225.     
  1226.     if(status==NODISK)
  1227.     {
  1228.         set(AP_SCDP,MUIA_Application_RexxString,"-1");
  1229.         return 5;
  1230.     }
  1231.     
  1232.     a=*((LONG *)args[0]);
  1233.     
  1234.     if(a<1 || a>TOClength)
  1235.     {
  1236.         set(AP_SCDP,MUIA_Application_RexxString,"-1");
  1237.         return 5;
  1238.     }
  1239.     
  1240.     useraction=0;
  1241.     
  1242.     sprintf(buff,"%d",TOCflags[a-1]);
  1243.     set(AP_SCDP,MUIA_Application_RexxString,buff);
  1244.  
  1245.     return 0;
  1246. }
  1247.  
  1248. static const struct Hook isdatatrackhook=
  1249. {
  1250.     {
  1251.         NULL,NULL
  1252.     },
  1253.     isdatatrackfunction,
  1254.     NULL,
  1255.     NULL
  1256. };
  1257.  
  1258. SAVEDS ASM LONG playfunction(REG(a0) struct Hook *hook, REG(a2) APTR app, REG(a1) LONG *args)
  1259. {
  1260.     if(status==NODISK)
  1261.         return 5;
  1262.         
  1263.     useraction=-1;
  1264.         
  1265.     DoMethod(AP_SCDP,MUIM_Application_ReturnID,ID_Play);
  1266.     return 0;
  1267. }
  1268.  
  1269. static const struct Hook playhook=
  1270. {
  1271.     {
  1272.         NULL,NULL
  1273.     },
  1274.     playfunction,
  1275.     NULL,
  1276.     NULL
  1277. };
  1278.  
  1279. SAVEDS ASM LONG stopfunction(REG(a0) struct Hook *hook, REG(a2) APTR app, REG(a1) LONG *args)
  1280. {
  1281.     if(status==NODISK)
  1282.         return 5;
  1283.         
  1284.     useraction=-1;
  1285.         
  1286.     DoMethod(AP_SCDP,MUIM_Application_ReturnID,ID_Stop);
  1287.     return 0;
  1288. }
  1289.  
  1290. static const struct Hook stophook=
  1291. {
  1292.     {
  1293.         NULL,NULL
  1294.     },
  1295.     stopfunction,
  1296.     NULL,
  1297.     NULL
  1298. };
  1299.  
  1300. SAVEDS ASM LONG pausefunction(REG(a0) struct Hook *hook, REG(a2) APTR app, REG(a1) LONG *args)
  1301. {
  1302.     if(status==NODISK)
  1303.         return 5;
  1304.     
  1305.     useraction=-1;
  1306.         
  1307.     DoMethod(AP_SCDP,MUIM_Application_ReturnID,ID_Pause);
  1308.     return 0;
  1309. }
  1310.  
  1311. static const struct Hook pausehook=
  1312. {
  1313.     {
  1314.         NULL,NULL
  1315.     },
  1316.     pausefunction,
  1317.     NULL,
  1318.     NULL
  1319. };
  1320.  
  1321. SAVEDS ASM LONG previousfunction(REG(a0) struct Hook *hook, REG(a2) APTR app, REG(a1) LONG *args)
  1322. {
  1323.     if(status==NODISK)
  1324.         return 5;
  1325.     
  1326.     useraction=-1;
  1327.     
  1328.     DoMethod(AP_SCDP,MUIM_Application_ReturnID,ID_Previous);
  1329.     return 0;
  1330. }
  1331.  
  1332. static const struct Hook previoushook=
  1333. {
  1334.     {
  1335.         NULL,NULL
  1336.     },
  1337.     previousfunction,
  1338.     NULL,
  1339.     NULL
  1340. };
  1341.  
  1342. SAVEDS ASM LONG nextfunction(REG(a0) struct Hook *hook, REG(a2) APTR app, REG(a1) LONG *args)
  1343. {
  1344.     if(status==NODISK)
  1345.         return 5;
  1346.     
  1347.     useraction=-1;
  1348.         
  1349.     DoMethod(AP_SCDP,MUIM_Application_ReturnID,ID_Next);
  1350.     return 0;
  1351. }
  1352.  
  1353. static const struct Hook nexthook=
  1354. {
  1355.     {
  1356.         NULL,NULL
  1357.     },
  1358.     nextfunction,
  1359.     NULL,
  1360.     NULL
  1361. };
  1362.  
  1363. SAVEDS ASM LONG rewindfunction(REG(a0) struct Hook *hook, REG(a2) APTR app, REG(a1) LONG *args)
  1364. {
  1365.     if(status==NODISK)
  1366.         return 5;
  1367.     
  1368.     useraction=-1;
  1369.         
  1370.     DoMethod(AP_SCDP,MUIM_Application_ReturnID,ID_Rewind);
  1371.     return 0;
  1372. }
  1373.  
  1374. static const struct Hook rewindhook=
  1375. {
  1376.     {
  1377.         NULL,NULL
  1378.     },
  1379.     rewindfunction,
  1380.     NULL,
  1381.     NULL
  1382. };
  1383.  
  1384. SAVEDS ASM LONG fastforwardfunction(REG(a0) struct Hook *hook, REG(a2) APTR app, REG(a1) LONG *args)
  1385. {
  1386.     if(status==NODISK)
  1387.         return 5;
  1388.     
  1389.     useraction=-1;
  1390.         
  1391.     DoMethod(AP_SCDP,MUIM_Application_ReturnID,ID_FastForward);
  1392.     return 0;
  1393. }
  1394.  
  1395. static const struct Hook fastforwardhook=
  1396. {
  1397.     {
  1398.         NULL,NULL
  1399.     },
  1400.     fastforwardfunction,
  1401.     NULL,
  1402.     NULL
  1403. };
  1404.  
  1405. SAVEDS ASM LONG ejectfunction(REG(a0) struct Hook *hook, REG(a2) APTR app, REG(a1) LONG *args)
  1406. {
  1407.     CDEject();
  1408.     
  1409.     useraction=0;
  1410.     
  1411.     return 0;
  1412. }
  1413.  
  1414. static const struct Hook ejecthook=
  1415. {
  1416.     {
  1417.         NULL,NULL
  1418.     },
  1419.     ejectfunction,
  1420.     NULL,
  1421.     NULL
  1422. };
  1423.  
  1424. SAVEDS ASM LONG loadfunction(REG(a0) struct Hook *hook, REG(a2) APTR app, REG(a1) LONG *args)
  1425. {
  1426.     if(status!=NODISK)
  1427.         return 5;
  1428.         
  1429.     useraction=0;
  1430.         
  1431.     CDLoad();
  1432.     return 0;
  1433. }
  1434.  
  1435. static const struct Hook loadhook=
  1436. {
  1437.     {
  1438.         NULL,NULL
  1439.     },
  1440.     loadfunction,
  1441.     NULL,
  1442.     NULL
  1443. };
  1444.  
  1445. SAVEDS ASM LONG volumefunction(REG(a0) struct Hook *hook, REG(a2) APTR app, REG(a1) LONG *args)
  1446. {
  1447.     char buff[16];
  1448.     int a;
  1449.     
  1450.     if(args[0])
  1451.     {
  1452.         a=*((LONG *)args[0]);
  1453.         set(SL_Volume,MUIA_Slider_Level,a);
  1454.     }
  1455.     
  1456.     get(SL_Volume,MUIA_Slider_Level,&a);
  1457.     sprintf(buff,"%d",a);
  1458.     set(AP_SCDP,MUIA_Application_RexxString,buff);  
  1459.     return 0;
  1460. }
  1461.  
  1462. static const struct Hook volumehook=
  1463. {
  1464.     {
  1465.         NULL,NULL
  1466.     },
  1467.     volumefunction,
  1468.     NULL,
  1469.     NULL
  1470. };
  1471.  
  1472. SAVEDS ASM LONG idfilenamefunction(REG(a0) struct Hook *hook, REG(a2) APTR app, REG(a1) LONG *args)
  1473. {
  1474.     if(status==NODISK)
  1475.         return 5;
  1476.     
  1477.     useraction=0;
  1478.     
  1479.     set(AP_SCDP,MUIA_Application_RexxString,TOCCDID);  
  1480.     return 0;
  1481. }
  1482.  
  1483. static const struct Hook idfilenamehook=
  1484. {
  1485.     {
  1486.         NULL,NULL
  1487.     },
  1488.     idfilenamefunction,
  1489.     NULL,
  1490.     NULL
  1491. };
  1492.  
  1493. SAVEDS ASM LONG diskspathfunction(REG(a0) struct Hook *hook, REG(a2) APTR app, REG(a1) LONG *args)
  1494. {
  1495.     if(status==NODISK)
  1496.         return 5;
  1497.     
  1498.     useraction=0;
  1499.     
  1500.     set(AP_SCDP,MUIA_Application_RexxString,diskspath);  
  1501.     return 0;
  1502. }
  1503.  
  1504. static const struct Hook diskspathhook=
  1505. {
  1506.     {
  1507.         NULL,NULL
  1508.     },
  1509.     diskspathfunction,
  1510.     NULL,
  1511.     NULL
  1512. };
  1513.  
  1514. SAVEDS ASM LONG closelistfunction(REG(a0) struct Hook *hook, REG(a2) APTR app, REG(a1) LONG *args)
  1515. {
  1516.     useraction=0;
  1517.     
  1518.     set(WI_List,MUIA_Window_Open,FALSE);  
  1519.     return 0;
  1520. }
  1521.  
  1522. static const struct Hook closelisthook=
  1523. {
  1524.     {
  1525.         NULL,NULL
  1526.     },
  1527.     closelistfunction,
  1528.     NULL,
  1529.     NULL
  1530. };
  1531.  
  1532. SAVEDS ASM LONG closeprogramfunction(REG(a0) struct Hook *hook, REG(a2) APTR app, REG(a1) LONG *args)
  1533. {
  1534.     useraction=0;
  1535.     
  1536.     set(WI_Program,MUIA_Window_Open,FALSE);  
  1537.     return 0;
  1538. }
  1539.  
  1540. static const struct Hook closeprogramhook=
  1541. {
  1542.     {
  1543.         NULL,NULL
  1544.     },
  1545.     closeprogramfunction,
  1546.     NULL,
  1547.     NULL
  1548. };
  1549.  
  1550. SAVEDS ASM LONG statusfunction(REG(a0) struct Hook *hook, REG(a2) APTR app, REG(a1) LONG *args)
  1551. {
  1552.     useraction=0;
  1553.     
  1554.     switch(status)
  1555.     {
  1556.         case NODISK:
  1557.             set(AP_SCDP,MUIA_Application_RexxString,"NODISK");
  1558.             break;  
  1559.         case STOPPED:
  1560.             set(AP_SCDP,MUIA_Application_RexxString,"STOPPED");
  1561.             break;  
  1562.         case PLAYING:
  1563.             set(AP_SCDP,MUIA_Application_RexxString,"PLAYING");
  1564.             break;  
  1565.         case PAUSED:
  1566.             set(AP_SCDP,MUIA_Application_RexxString,"PAUSED");
  1567.             break;  
  1568.     }
  1569.     return 0;
  1570. }
  1571.  
  1572. static const struct Hook statushook=
  1573. {
  1574.     {
  1575.         NULL,NULL
  1576.     },
  1577.     statusfunction,
  1578.     NULL,
  1579.     NULL
  1580. };
  1581.  
  1582. SAVEDS ASM LONG useractionfunction(REG(a0) struct Hook *hook, REG(a2) APTR app, REG(a1) LONG *args)
  1583. {
  1584.     if(quitting)
  1585.     {
  1586.         set(AP_SCDP,MUIA_Application_RexxString,"2");
  1587.         return 0;
  1588.     }
  1589.     
  1590.     switch(useraction)
  1591.     {
  1592.         case -1:
  1593.         case 0:
  1594.             set(AP_SCDP,MUIA_Application_RexxString,"0");
  1595.             break;  
  1596.         case 1:
  1597.             set(AP_SCDP,MUIA_Application_RexxString,"1");
  1598.             break;  
  1599.     }
  1600.     
  1601.     useraction=0;
  1602.     
  1603.     return 0;
  1604. }
  1605.  
  1606. static const struct Hook useractionhook=
  1607. {
  1608.     {
  1609.         NULL,NULL
  1610.     },
  1611.     useractionfunction,
  1612.     NULL,
  1613.     NULL
  1614. };
  1615.  
  1616. SAVEDS ASM LONG sleepfunction(REG(a0) struct Hook *hook, REG(a2) APTR app, REG(a1) LONG *args)
  1617. {
  1618.     int a=0;
  1619.     char buff[10];
  1620.     
  1621.     useraction=0;
  1622.     
  1623.     a=*((LONG *)args[0]);
  1624.     if(a)
  1625.         a=1;
  1626.     set(AP_SCDP,MUIA_Application_Sleep,a);
  1627.     
  1628.     return 0;
  1629. }
  1630.  
  1631. static const struct Hook sleephook=
  1632. {
  1633.     {
  1634.         NULL,NULL
  1635.     },
  1636.     sleepfunction,
  1637.     NULL,
  1638.     NULL
  1639. };
  1640.  
  1641. struct MUI_Command rxcmds[]=
  1642. {                                                                                           /*  Done  */
  1643.     {"PLAYRAW",     "STARTADDRESS/N/A,ENDADDRESS/N",        2,      &playrawhook},              /**/
  1644.     {"PLAYTRACK",   "TRACK/N/A",                            1,      &playtrackhook},            /**/
  1645.     {"PLAYINGPOS",  NULL,                                   0,      &playingposhook},           /**/
  1646.     {"PLAYINGTRACK",  NULL,                                 0,      &playingtrackhook},         /**/
  1647.     {"PROGRAM",     "NEW/N",                                1,      &programhook},              /**/
  1648.     {"SHUFFLE",     "NEW/N",                                1,      &shufflehook},              /**/
  1649.     {"REPEAT",      "NEW/N",                                1,      &repeathook},               /**/
  1650.     {"AUTOPROGRAM", "NEW/N",                                1,      &autoprogramhook},          /**/
  1651.     {"AUTOSHUFFLE", "NEW/N",                                1,      &autoshufflehook},          /**/
  1652.     {"AUTOREPEAT",  "NEW/N",                                1,      &autorepeathook},           /**/
  1653.     {"AUTOPLAY",    "NEW/N",                                1,      &autoplayhook},             /**/
  1654.     {"SETPROGRAM",  "TRACKNUMBERS/N/M",                     1,      &setprogramhook},           /**/
  1655.     {"PROGRAMMEDTRACKS",    NULL,                           0,      &programmedtrackshook},     /**/
  1656.     {"PROGRAMMEDTRACK", "NUMBER/N,NEW/N",                   2,      &programmedtrackhook},      /**/
  1657.     {"ADDPROGRAMMEDTRACK",  "NUMBER/N/A",                   1,      &addprogrammedtrackhook},   /**/
  1658.     {"SAVEPROGRAM", MC_TEMPLATE_ID,                         ID_PRexxSave,   NULL},              /**/
  1659.     {"CDTITLE",     "TITLE",                                1,      &cdtitlehook},              /**/
  1660.     {"CDARTIST",    "ARTIST",                               1,      &cdartisthook},             /**/
  1661.     {"TRACKS",      NULL,                                   0,      &cdtrackshook},             /**/
  1662.     {"TRACKNAME",   "NUMBER/N/A,NAME",                      2,      &tracknamehook},            /**/
  1663.     {"TRACKSTART",  "NUMBER/N/A",                           1,      &trackstarthook},           /**/
  1664.     {"TRACKEND",    "NUMBER/N/A",                           1,      &trackendhook},             /**/
  1665.     {"ISDATATRACK", "NUMBER/N/A",                           1,      &isdatatrackhook},          /**/
  1666.     {"SAVECDDATA",  MC_TEMPLATE_ID,                         ID_RexxSave,    NULL},              /**/
  1667.     {"PLAY",        NULL,                                   0,      &playhook},                 /**/
  1668.     {"STOP",        NULL,                                   0,      &stophook},                 /**/
  1669.     {"PAUSE",       NULL,                                   0,      &pausehook},                /**/
  1670.     {"PREVIOUS",    NULL,                                   0,      &previoushook},             /**/
  1671.     {"NEXT",        NULL,                                   0,      &nexthook},                 /**/
  1672.     {"REWIND",      NULL,                                   0,      &rewindhook},               /**/
  1673.     {"FASTFORWARD", NULL,                                   0,      &fastforwardhook},          /**/
  1674.     {"EJECT",       NULL,                                   0,      &ejecthook},                /**/
  1675.     {"LOAD",        NULL,                                   0,      &loadhook},                 /**/
  1676.     {"VOLUME",      "LEVEL/N",                              1,      &volumehook},               /**/
  1677.     {"IDFILENAME",  NULL,                                   0,      &idfilenamehook},           /**/
  1678.     {"DISKSPATH",   NULL,                                   0,      &diskspathhook},            /**/
  1679.     {"OPENLIST",    MC_TEMPLATE_ID,                         ID_List,    NULL},                  /**/
  1680.     {"CLOSELIST",   NULL,                                   0,      &closelisthook},            /**/
  1681.     {"OPENPROGRAM", MC_TEMPLATE_ID,                         ID_ProgramR,    NULL},              /**/
  1682.     {"CLOSEPROGRAM",    NULL,                               0,      &closeprogramhook},         /**/
  1683.     {"STATUS",      NULL,                                   0,      &statushook},               /**/
  1684.     {"USERACTION",  NULL,                                   0,      &useractionhook},           /**/
  1685.     {"SLEEP", "NEW/N/A",                                    1,      &sleephook},                /**/
  1686.     {NULL,NULL,NULL,NULL}
  1687. };
  1688.  
  1689. /* Some more vars for ARexx support */
  1690. BOOL rexxok=FALSE;
  1691. char scriptonstart[256]="";
  1692. char scriptonquit[256]="";
  1693. char scriptoninsert[256]="";
  1694. char menuscripts[8][256]={"","","","","","","",""};
  1695. char buttonscripts[8][256]={"","","","","","","",""};
  1696. char buttonimages[8][256]={"","","","","","","",""};
  1697. int menuscriptsno=0;
  1698. int buttonscriptsno=0;
  1699. struct MsgPort *rxmp=NULL;
  1700. int rxmsgs=0;
  1701.  
  1702. int StartARexx(void)
  1703. {   
  1704.     if((rxmp=CreateMsgPort()) && (FindPort("REXX")))
  1705.     {
  1706.         rexxok=TRUE;
  1707.     }
  1708.     return rexxok;
  1709. }
  1710.  
  1711. void LaunchARexxScript(char *command)
  1712. {
  1713.     struct RexxMsg *rxmsg=NULL;
  1714.     struct MsgPort *rp=NULL;
  1715.     char *strptr;
  1716.  
  1717.     BOOL ok=FALSE;
  1718.     
  1719.     if(!rexxok || quitting)
  1720.         return;
  1721.  
  1722.     if(rxmsgs)
  1723.     {
  1724.         while(rxmsg=GetMsg(rxmp))
  1725.         {
  1726.             ClearRexxMsg(rxmsg,1);
  1727.             DeleteRexxMsg(rxmsg);
  1728.             rxmsgs--;
  1729.         }
  1730.     }
  1731.     
  1732.     get(AP_SCDP,MUIA_Application_Base,&strptr);
  1733.     
  1734.     if(rxmsg=CreateRexxMsg(rxmp,"scdp",strptr))
  1735.     {
  1736.         if (rxmsg->rm_Args[0]=CreateArgstring(command,strlen(command)))
  1737.         {
  1738.             rxmsg->rm_Action=RXCOMM|RXFF_NOIO;
  1739.             
  1740.             Forbid();
  1741.             if(rp=FindPort("REXX"))
  1742.             {
  1743.                 PutMsg(rp,(struct Message *) rxmsg);
  1744.                     
  1745.                 Permit();
  1746.                 
  1747.                 rxmsgs++;
  1748.                 ok=TRUE;
  1749.             }   
  1750.             else
  1751.                 Permit();
  1752.                 
  1753.             if(!ok)
  1754.                 ClearRexxMsg(rxmsg,1);
  1755.         }
  1756.         if(!ok)
  1757.             DeleteRexxMsg(rxmsg);
  1758.     }   
  1759. }
  1760.  
  1761. void EndARexx(void)
  1762. {
  1763.     struct RexxMsg *rxmsg=NULL;
  1764.     
  1765.     if(rexxok)
  1766.     {
  1767.         while(rxmsgs)
  1768.         {
  1769.             WaitPort(rxmp);
  1770.             while(rxmsg=GetMsg(rxmp))
  1771.             {
  1772.                 ClearRexxMsg(rxmsg,1);
  1773.                 DeleteRexxMsg(rxmsg);
  1774.                 rxmsgs--;
  1775.             }
  1776.         }
  1777.         DeleteMsgPort(rxmp);
  1778.     }
  1779. }
  1780.  
  1781. /* Main program at last */
  1782. int main(int argc, char *argv[])
  1783. {
  1784.     char *errorstr=NULL;
  1785.     int i,vamos,a,b;
  1786.     ULONG signals;
  1787.     char buff[256];
  1788.     UBYTE *strptr=NULL;
  1789.     struct DiskObject *mydo;
  1790.     FILE *f;
  1791.     BPTR l;
  1792.  
  1793.     if(stacksize()<STACKSIZE)
  1794.         fail(NULL,glstr(MSG_FailStack));
  1795.  
  1796.     if(argc==0)
  1797.     {
  1798.         argc=_WBArgc;
  1799.         argv=_WBArgv;
  1800.     }
  1801.  
  1802.     i=strlen(argv[0]);
  1803.     while(argv[0][i]!='/' && argv[0][i]!=':' && i)
  1804.         i--;
  1805.  
  1806.     if(argv[0][i]=='/' || argv[0][i]==':')
  1807.         sprintf(buff,"PROGDIR:%s",argv[0]+i+1);
  1808.     else
  1809.         sprintf(buff,"PROGDIR:%s",argv[0]);
  1810.  
  1811.     init();
  1812.  
  1813.     mydo=GetDiskObject(buff);
  1814.  
  1815.     for(a=1;a<argc;a++)
  1816.     {
  1817.         if(!strncmp(argv[a],"DEVICE=",7))
  1818.             strcpy(scsidev,argv[a]+7);
  1819.         if(!strncmp(argv[a],"UNIT=",5))
  1820.             scsiid=atoi(argv[a]+5);
  1821.         if(!strcmp(argv[a],"NOVOLUME"))
  1822.             volumecontrol=FALSE;
  1823.         if(!strcmp(argv[a],"CUSTOMFONTS"))
  1824.             customfonts=TRUE;
  1825.         if(!strncmp(argv[a],"NORMALFONT=",11))
  1826.             normalname=argv[a]+11;
  1827.         if(!strncmp(argv[a],"TINYFONT=",9))
  1828.             tinyname=argv[a]+9;
  1829.         if(!strncmp(argv[a],"FIXEDFONT=",10))
  1830.             fixedname=argv[a]+10;
  1831.         if(!strncmp(argv[a],"LISTFONT=",9))
  1832.             listname=argv[a]+9;
  1833.         if(!strncmp(argv[a],"TITLEFONT=",10))
  1834.             titlename=argv[a]+10;
  1835.  
  1836.         if(!strncmp(argv[a],"CX_POPUP=",9))
  1837.         {
  1838.             if(!strcmp("NO",argv[a]+9))
  1839.                 popupflag=0;
  1840.             if(!strcmp("YES",argv[a]+9))
  1841.                 popupflag=1;
  1842.         }
  1843.         if(!strncmp(argv[a],"CX_POPKEY=",10))
  1844.             strcpy(hotkeys[11],argv[a]+10);
  1845.         if(!strncmp(argv[a],"PLAY_KEY=",9))
  1846.             strcpy(hotkeys[0],argv[a]+9);
  1847.         if(!strncmp(argv[a],"PAUSE_KEY=",10))
  1848.             strcpy(hotkeys[1],argv[a]+10);
  1849.         if(!strncmp(argv[a],"STOP_KEY=",9))
  1850.             strcpy(hotkeys[2],argv[a]+9);
  1851.         if(!strncmp(argv[a],"PREVIOUS_KEY=",13))
  1852.             strcpy(hotkeys[3],argv[a]+13);
  1853.         if(!strncmp(argv[a],"NEXT_KEY=",9))
  1854.             strcpy(hotkeys[4],argv[a]+9);
  1855.         if(!strncmp(argv[a],"REWIND_KEY=",11))
  1856.             strcpy(hotkeys[5],argv[a]+11);
  1857.         if(!strncmp(argv[a],"FASTFORWARD_KEY=",16))
  1858.             strcpy(hotkeys[6],argv[a]+16);
  1859.         if(!strncmp(argv[a],"EJECT_KEY=",10))
  1860.             strcpy(hotkeys[7],argv[a]+10);
  1861.         if(!strncmp(argv[a],"PROGRAM_KEY=",12))
  1862.             strcpy(hotkeys[8],argv[a]+12);
  1863.         if(!strncmp(argv[a],"SHUFFLE_KEY=",12))
  1864.             strcpy(hotkeys[9],argv[a]+12);
  1865.         if(!strncmp(argv[a],"REPEAT_KEY=",11))
  1866.             strcpy(hotkeys[10],argv[a]+11);
  1867.             
  1868.         if(!strncmp(argv[a],"DISKSPATH=",10))
  1869.             strcpy(diskspath,argv[a]+10);
  1870.  
  1871.         if(!strncmp(argv[a],"SCRIPTONSTART=",14))
  1872.             strcpy(scriptonstart,argv[a]+14);
  1873.         if(!strncmp(argv[a],"SCRIPTONQUIT=",13))
  1874.             strcpy(scriptonquit,argv[a]+13);
  1875.         if(!strncmp(argv[a],"SCRIPTONINSERT=",15))
  1876.             strcpy(scriptoninsert,argv[a]+15);
  1877.             
  1878.         if(!strncmp(argv[a],"MENUSCRIPT=",11) && menuscriptsno<8)
  1879.             strcpy(menuscripts[menuscriptsno++],argv[a]+11);
  1880.         
  1881.         if(!strncmp(argv[a],"BUTTONSCRIPT=",13) && buttonscriptsno<8)
  1882.         {
  1883.             char *p;
  1884.             int i=0;
  1885.             
  1886.             p=argv[a]+13;
  1887.             
  1888.             while(*p!='|' && *p!='\0')
  1889.             {
  1890.                 buttonscripts[buttonscriptsno][i++]=*p++;
  1891.             }
  1892.             if((*p++)=='|')
  1893.             {
  1894.                 buttonscripts[buttonscriptsno][i]='\0';
  1895.                 strcpy(buttonimages[buttonscriptsno],"4:PROGDIR:Images/");
  1896.                 strcat(buttonimages[buttonscriptsno],p);
  1897.                 buttonscriptsno++;
  1898.             }
  1899.         }
  1900.     }
  1901.  
  1902.     if(l=Lock(diskspath,ACCESS_READ))
  1903.     {
  1904.         NameFromLock(l,diskspath,512);
  1905.         UnLock(l);
  1906.     }
  1907.  
  1908.     if(diskspath[0] && diskspath[strlen(diskspath)-1]!='/' && diskspath[strlen(diskspath)-1]!=':')
  1909.     {
  1910.         strcat(diskspath,"/");
  1911.     }
  1912.  
  1913.     if(customfonts)
  1914.     {
  1915.         normalfont=getfont(normalname);
  1916.         tinyfont=getfont(tinyname);
  1917.         fixedfont=getfont(fixedname);
  1918.         listfont=getfont(listname);
  1919.         titlefont=getfont(titlename);
  1920.  
  1921.         if(!normalfont || !tinyfont || !fixedfont || !listfont || !titlefont)
  1922.             fail(NULL,glstr(MSG_FailNoFont));
  1923.     }
  1924.  
  1925.     if(msgport=CreateMsgPort())
  1926.     {
  1927.         if(ioreq=CreateIORequest(msgport,sizeof(IOSTDREQ)))
  1928.         {
  1929.             if(!(OpenDevice(scsidev,scsiid,(struct IORequest *)ioreq,0)))
  1930.             {
  1931.                 if(scsicmd=AllocMem(sizeof(SCSICMD), MEMF_CHIP|MEMF_CLEAR|MEMF_PUBLIC))
  1932.                 {
  1933.                     if(scsisense=AllocMem(SENSE_LEN, MEMF_CHIP|MEMF_CLEAR|MEMF_PUBLIC))
  1934.                     {
  1935.                         if(tmsgport=CreateMsgPort())
  1936.                         {
  1937.                             if(tioreq=CreateIORequest(tmsgport,sizeof(struct timerequest)))
  1938.                             {
  1939.                                 if(!(OpenDevice(TIMERNAME,UNIT_VBLANK,(struct IORequest *)tioreq,0)))
  1940.                                 {
  1941.                                     if(scsidata=AllocMem(MAX_DATA_LEN,MEMF_CHIP|MEMF_CLEAR|MEMF_PUBLIC))
  1942.                                     {
  1943.                                         if(TOCbuf=AllocMem(MAX_TOC_LEN,MEMF_CHIP|MEMF_PUBLIC))
  1944.                                         {
  1945.                                             programmed[0]=0;
  1946.  
  1947.                                             menudata[0].nm_Label=glstr(MSG_MenuProject);
  1948.                                             menudata[1].nm_Label=glstr(MSG_MenuAbout);
  1949.                                             menudata[1].nm_CommKey=glstr(MSG_MenuAboutKey);
  1950.                                             menudata[2].nm_Label=glstr(MSG_MenuAboutMUI);
  1951.                                             menudata[4].nm_Label=glstr(MSG_MenuQuit);
  1952.                                             menudata[4].nm_CommKey=glstr(MSG_MenuQuitKey);
  1953.                                             menudata[5].nm_Label=glstr(MSG_MenuSettings);
  1954.                                             menudata[6].nm_Label=glstr(MSG_MenuMUI);
  1955.                                             menudata[7].nm_Label=glstr(MSG_ARexx);
  1956.                                             menudata[8].nm_Label=glstr(MSG_Execute);
  1957.                                             for(a=0;a<menuscriptsno;a++)
  1958.                                             {
  1959.                                                 char *p,*q;
  1960.                                                 p=q=menuscripts[a];
  1961.                                                 while(*q)
  1962.                                                 {
  1963.                                                     if(*q=='/' || *q==':')
  1964.                                                         p=q+1;
  1965.                                                     q++;
  1966.                                                 }
  1967.                                                 menudata[10+a].nm_Label=p;
  1968.                                             }
  1969.                                             menudata[a+10].nm_Type=NM_END;
  1970.                                             menudata[a+10].nm_Label=NULL;
  1971.                                             menudata[a+10].nm_Flags=0;
  1972.                                             menudata[a+10].nm_UserData=NULL;
  1973.                                             
  1974.                                             regtitles[0]=glstr(MSG_TitleList);
  1975.                                             regtitles[1]=glstr(MSG_ProgramList);
  1976.  
  1977.                                             AP_SCDP=NULL;
  1978.  
  1979.                                             CL_ProgramList=MUI_CreateCustomClass(NULL,MUIC_List,NULL,sizeof(struct ProgramList_Data),ProgramList_Dispatcher);
  1980.  
  1981.                                             if(CL_ProgramList)
  1982.                                             {
  1983.                                                 AP_SCDP = ApplicationObject,
  1984.                                                     MUIA_Application_Title,         "SCDPlayer",
  1985.                                                     MUIA_Application_Version,       "$VER: SCDPlayer " VERSION " (" __DATE__ " " __TIME__ ")",
  1986.                                                     MUIA_Application_Copyright,     "Copyright ©1996, Juan J. García de Soria",
  1987.                                                     MUIA_Application_Author,        "Juan J. García de Soria",
  1988.                                                     MUIA_Application_Description,   glstr(MSG_SCDPDescription),
  1989.                                                     MUIA_Application_Base,          "SCDP",
  1990.                                                     MUIA_Application_DiskObject,    mydo,
  1991.                                                     MUIA_Application_Menustrip,MN_Menu=MUI_MakeObject(MUIO_MenustripNM,menudata,0),
  1992.                                                     MUIA_Application_SingleTask,TRUE,
  1993.                                                     MUIA_Application_BrokerHook,&brokerhook,
  1994.                                                     MUIA_Application_Commands,rxcmds,
  1995.                                                     SubWindow,
  1996.                                                         WI_SCDP=WindowObject,
  1997.                                                         MUIA_Window_Title, "SCDPlayer " VERSION,
  1998.                                                         MUIA_Window_ID,MAKE_ID('S','C','D','P'),
  1999.                                                         WindowContents,HGroup,
  2000.                                                             MUIA_Background,MUII_WindowBack,
  2001.                                                             MUIA_Font,(customfonts)?(ULONG)normalfont:MUIV_Font_Normal,
  2002.                                                             Child,VGroup,   /* Lado izquierdo de la ventana */
  2003.                                                                 MUIA_Background,MUII_WindowBack,
  2004.                                                                 MUIA_Weight,1,
  2005.                                                                 Child,VGroup,
  2006.                                                                     MUIA_VertDisappear,1,
  2007.                                                                     MUIA_Background,MUII_TextBack,
  2008.                                                                     MUIA_Weight,70,
  2009.                                                                     TextFrame,
  2010.                                                                     Child,VSpace(0),
  2011.                                                                     Child,HGroup,
  2012.                                                                         Child,HSpace(0),
  2013.                                                                         Child,BitmapObject,
  2014.                                                                             MUIA_FixWidth,232,
  2015.                                                                             MUIA_FixHeight,30,
  2016.                                                                             MUIA_Bitmap_Bitmap,&logobm,
  2017.                                                                             MUIA_Bitmap_Transparent,0,
  2018.                                                                             MUIA_Bitmap_Width,232,
  2019.                                                                             MUIA_Bitmap_Height,30,
  2020.                                                                             MUIA_Bitmap_SourceColors,logocolours,
  2021.                                                                             End,
  2022.                                                                         Child,HSpace(0),
  2023.                                                                         End,
  2024.                                                                     Child,VSpace(0),
  2025.                                                                     End,
  2026.                                                                 Child,VGroup,   /* Zona de estado */
  2027.                                                                     MUIA_VertDisappear,2,
  2028.                                                                     MUIA_Background,MUII_TextBack,
  2029.                                                                     GroupFrame,
  2030.                                                                     MUIA_ShortHelp,glstr(MSG_HelpInfo),
  2031.                                                                     Child,VSpace(0),
  2032.                                                                     Child,HGroup,   /* Los tres indicadores */
  2033.                                                                         Child,VGroup,   /* Nº de pista */
  2034.                                                                             MUIA_Weight,0,
  2035.                                                                             Child,TextObject,
  2036.                                                                                 MUIA_Font,(customfonts)?(ULONG)tinyfont:MUIV_Font_Tiny,
  2037.                                                                                 MUIA_Text_Contents,glstr(MSG_Track),
  2038.                                                                                 MUIA_Text_PreParse,"\33l",
  2039.                                                                                 End,
  2040.                                                                             Child,TX_Track=TextObject,
  2041.                                                                                 MUIA_Font,(customfonts)?(ULONG)fixedfont:MUIV_Font_Fixed,
  2042.                                                                                 MUIA_Text_Contents,"--",
  2043.                                                                                 MUIA_Text_PreParse,"\33l",
  2044.                                                                                 End,
  2045.                                                                             End,
  2046.                                                                         Child,HSpace(0),
  2047.                                                                         Child,VGroup,   /* Posición en pista actual */
  2048.                                                                             MUIA_Weight,0,
  2049.                                                                             Child,TextObject,
  2050.                                                                                 MUIA_Font,(customfonts)?(ULONG)tinyfont:MUIV_Font_Tiny,
  2051.                                                                                 MUIA_Text_Contents,glstr(MSG_TitleTime),
  2052.                                                                                 MUIA_Text_PreParse,"\33l",
  2053.                                                                                 End,
  2054.                                                                             Child,TX_TitleTime=TextObject,
  2055.                                                                                 MUIA_Font,(customfonts)?(ULONG)fixedfont:MUIV_Font_Fixed,
  2056.                                                                                 MUIA_Text_Contents,"--:--/--:--",
  2057.                                                                                 MUIA_Text_PreParse,"\33l",
  2058.                                                                                 End,
  2059.                                                                             End,
  2060.                                                                         Child,HSpace(0),
  2061.                                                                         Child,VGroup,   /* Posición en todo el CD */
  2062.                                                                             MUIA_Weight,0,
  2063.                                                                             Child,TextObject,
  2064.                                                                                 MUIA_Font,(customfonts)?(ULONG)tinyfont:MUIV_Font_Tiny,
  2065.                                                                                 MUIA_Text_Contents,glstr(MSG_CDTime),
  2066.                                                                                 MUIA_Text_PreParse,"\33l",
  2067.                                                                                 End,
  2068.                                                                             Child,TX_CDTime=TextObject,
  2069.                                                                                 MUIA_Font,(customfonts)?(ULONG)fixedfont:MUIV_Font_Fixed,
  2070.                                                                                 MUIA_Text_Contents,"--:--/--:--",
  2071.                                                                                 MUIA_Text_PreParse,"\33l",
  2072.                                                                                 End,
  2073.                                                                             End,
  2074.                                                                         End,
  2075.                                                                     Child,TX_Artist=TextObject,
  2076.                                                                         MUIA_Font,(customfonts)?(ULONG)normalfont:MUIV_Font_Normal,
  2077.                                                                         MUIA_Text_SetMin,FALSE,
  2078.                                                                         MUIA_Text_Contents,glstr(MSG_NoDisc),
  2079.                                                                         MUIA_Text_PreParse,"\33l",
  2080.                                                                         End,
  2081.                                                                     Child,TX_Title=TextObject,
  2082.                                                                         MUIA_Text_SetMin,FALSE,
  2083.                                                                         MUIA_Font,(customfonts)?(ULONG)normalfont:MUIV_Font_Normal,
  2084.                                                                         MUIA_Text_Contents,"",
  2085.                                                                         MUIA_Text_PreParse,"\33l",
  2086.                                                                         End,
  2087.                                                                     Child,VSpace(0),
  2088.                                                                     End,
  2089.                                                                 Child,HGroup,
  2090.                                                                     MUIA_Background,MUII_GroupBack,
  2091.                                                                     GroupFrame,
  2092.                                                                     Child,HSpace(0),
  2093.                                                                     Child,VGroup,
  2094.                                                                         Child,VSpace(0),
  2095.                                                                         Child,HGroup,
  2096.                                                                             MUIA_Weight,0,
  2097.                                                                             Child,BT_Play=MyImageButton("Play",' ',MSG_HelpPlay),
  2098.                                                                             Child,BT_Pause=MyImageButton("Pause",'.',MSG_HelpPause),
  2099.                                                                             Child,BT_Stop=MyImageButton("Stop",'s',MSG_HelpStop),
  2100.                                                                             Child,BT_Previous=MyImageButton("Previous",'p',MSG_HelpPrevious),
  2101.                                                                             Child,BT_Next=MyImageButton("Next",'n',MSG_HelpNext),
  2102.                                                                             Child,BT_Rewind=MyImageButton("Rewind",'r',MSG_HelpRewind),
  2103.                                                                             Child,BT_FastForward=MyImageButton("FastForward",'f',MSG_HelpFastForward),
  2104.                                                                             Child,BT_Eject=MyImageButton("Eject",'e',MSG_HelpEject),
  2105.                                                                             End,
  2106.                                                                         Child,HGroup,
  2107.                                                                             Child,BT_A[0]=(buttonscriptsno>0)?MyImageButtonNH(buttonimages[0],'1'):HSpace(0),
  2108.                                                                             Child,BT_A[1]=(buttonscriptsno>1)?MyImageButtonNH(buttonimages[1],'2'):HSpace(0),
  2109.                                                                             Child,BT_A[2]=(buttonscriptsno>2)?MyImageButtonNH(buttonimages[2],'3'):HSpace(0),
  2110.                                                                             Child,BT_A[3]=(buttonscriptsno>3)?MyImageButtonNH(buttonimages[3],'4'):HSpace(0),
  2111.                                                                             Child,BT_A[4]=(buttonscriptsno>4)?MyImageButtonNH(buttonimages[4],'5'):HSpace(0),
  2112.                                                                             Child,BT_A[5]=(buttonscriptsno>5)?MyImageButtonNH(buttonimages[5],'6'):HSpace(0),
  2113.                                                                             Child,BT_A[6]=(buttonscriptsno>6)?MyImageButtonNH(buttonimages[6],'7'):HSpace(0),
  2114.                                                                             Child,BT_A[7]=(buttonscriptsno>7)?MyImageButtonNH(buttonimages[7],'8'):HSpace(0),
  2115.                                                                             End,
  2116.                                                                         Child,HGroup,
  2117.                                                                             Child,MyImage("VolumeLow"),
  2118.                                                                             Child,SL_Volume=SliderObject,
  2119.                                                                                 MUIA_ShortHelp,glstr(MSG_HelpVolume),
  2120.                                                                                 MUIA_Slider_Min,1,
  2121.                                                                                 MUIA_Slider_Max,31,
  2122.                                                                                 MUIA_Slider_Level,16,
  2123.                                                                                 MUIA_Slider_Quiet,TRUE,
  2124.                                                                                 End,
  2125.                                                                             Child,MyImage("VolumeHigh"),
  2126.                                                                             Child,BT_ProgramL=MyImageButton2("Program",'o',MSG_HelpProgramL),
  2127.                                                                             Child,BT_Shuffle=MyImageButton2("Shuffle",'q',MSG_HelpShuffle),
  2128.                                                                             Child,BT_Repeat=MyImageButton2("Repeat",'a',MSG_HelpRepeat),
  2129.                                                                             End,
  2130.                                                                         Child,VSpace(0),
  2131.                                                                         End,
  2132.                                                                     Child,HSpace(0),
  2133.                                                                     End,
  2134.                                                                 End,
  2135.                                                             Child,BalanceObject,
  2136.                                                                 MUIA_Weight,1,
  2137.                                                                 MUIA_HorizDisappear,1,
  2138.                                                                 End,
  2139.                                                             Child,VGroup,   /* Lado derecho de la ventana */
  2140.                                                                 MUIA_HorizDisappear,1,
  2141.                                                                 MUIA_Weight,99,
  2142.                                                                 MUIA_Background,MUII_GroupBack,
  2143.                                                                 GroupFrame,
  2144.                                                                 Child,RG_RegTraPro=RegisterGroup(regtitles),
  2145.                                                                     MUIA_Background,MUII_RegisterBack,
  2146.                                                                     Child,LV_TrackSelect=ListviewObject,
  2147.                                                                         MUIA_ShortHelp,glstr(MSG_HelpTrackSelect),
  2148.                                                                         MUIA_Listview_List,ListObject,
  2149.                                                                             ReadListFrame,
  2150.                                                                             MUIA_Font,(customfonts)?(ULONG)listfont:MUIV_Font_List,
  2151.                                                                             MUIA_List_ConstructHook,MUIV_List_ConstructHook_String,
  2152.                                                                             MUIA_List_DestructHook,MUIV_List_DestructHook_String,
  2153.                                                                             MUIA_Background,MUII_ListBack,
  2154.                                                                             End,
  2155.                                                                         End,
  2156.                                                                     Child,LV_ProgramSelect=ListviewObject,
  2157.                                                                         MUIA_ShortHelp,glstr(MSG_HelpTrackSelect),
  2158.                                                                         MUIA_Listview_List,ListObject,
  2159.                                                                             ReadListFrame,
  2160.                                                                             MUIA_Font,(customfonts)?(ULONG)listfont:MUIV_Font_List,
  2161.                                                                             MUIA_List_ConstructHook,MUIV_List_ConstructHook_String,
  2162.                                                                             MUIA_List_DestructHook,MUIV_List_DestructHook_String,
  2163.                                                                             MUIA_Background,MUII_ListBack,
  2164.                                                                             End,
  2165.                                                                         End,
  2166.                                                                     End,
  2167.                                                                 Child,HGroup,
  2168.                                                                     Child,BT_List=SimpleButton(glstr(MSG_ListButton)),
  2169.                                                                     Child,BT_ProgramR=SimpleButton(glstr(MSG_ProgramButton)),
  2170.                                                                     End,
  2171.                                                                 End,
  2172.                                                             End,
  2173.                                                         End,
  2174.                                                     SubWindow,
  2175.                                                         WI_List=WindowObject,
  2176.                                                         MUIA_Window_Title, glstr(MSG_CDInformation),
  2177.                                                         MUIA_Window_ID,MAKE_ID('L','I','S','T'),
  2178.                                                         WindowContents,VGroup,
  2179.                                                             MUIA_Background,MUII_WindowBack,
  2180.                                                             MUIA_Font,(customfonts)?(ULONG)normalfont:MUIV_Font_Normal,
  2181.                                                             Child,ColGroup(2),
  2182.                                                                 Child,Label2(glstr(MSG_Artist)),
  2183.                                                                 Child,ST_Artist=StringObject,
  2184.                                                                     StringFrame,
  2185.                                                                     MUIA_ShortHelp,glstr(MSG_HelpArtist),
  2186.                                                                     MUIA_String_MaxLen,127,
  2187.                                                                     End,
  2188.                                                                 Child,Label2(glstr(MSG_CDTitle)),
  2189.                                                                 Child,ST_CDTitle=StringObject,
  2190.                                                                     StringFrame,
  2191.                                                                     MUIA_ShortHelp,glstr(MSG_HelpCDTitle),
  2192.                                                                     MUIA_String_MaxLen,127,
  2193.                                                                     End,
  2194.                                                                 End,
  2195.                                                             Child,TextObject,
  2196.                                                                 MUIA_Font,(customfonts)?(ULONG)titlefont:MUIV_Font_Title,
  2197.                                                                 MUIA_Text_Contents,glstr(MSG_TitleList),
  2198.                                                                 MUIA_Text_PreParse,"\33c",
  2199.                                                                 End,
  2200.                                                             Child,LV_TitleList=ListviewObject,
  2201.                                                                 MUIA_Listview_List,ListObject,
  2202.                                                                     MUIA_Font,(customfonts)?(ULONG)listfont:MUIV_Font_List,
  2203.                                                                     MUIA_ShortHelp,glstr(MSG_HelpTitles),
  2204.                                                                     InputListFrame,
  2205.                                                                     MUIA_List_ConstructHook,MUIV_List_ConstructHook_String,
  2206.                                                                     MUIA_List_DestructHook,MUIV_List_DestructHook_String,
  2207.                                                                     MUIA_Background,MUII_ListBack,
  2208.                                                                     End,
  2209.                                                                 End,
  2210.                                                             Child,ST_Title=StringObject,
  2211.                                                                 StringFrame,
  2212.                                                                 MUIA_ShortHelp,glstr(MSG_HelpTitle),
  2213.                                                                 MUIA_String_MaxLen,127,
  2214.                                                                 MUIA_String_AttachedList,LV_TitleList,
  2215.                                                                 End,
  2216.                                                             Child,ColGroup(4),
  2217.                                                                 Child,Label1(glstr(MSG_AutoPlay)),
  2218.                                                                 Child,CH_AutoPlay=CheckMarkH(0,glstr(MSG_HelpAutoPlay)),
  2219.                                                                 Child,Label1(glstr(MSG_AutoProgram)),
  2220.                                                                 Child,CH_AutoProgram=CheckMarkH(0,glstr(MSG_HelpAutoProgram)),
  2221.                                                                 Child,Label1(glstr(MSG_AutoShuffle)),
  2222.                                                                 Child,CH_AutoShuffle=CheckMarkH(0,glstr(MSG_HelpAutoShuffle)),
  2223.                                                                 Child,Label1(glstr(MSG_AutoRepeat)),
  2224.                                                                 Child,CH_AutoRepeat=CheckMarkH(0,glstr(MSG_HelpAutoRepeat)),
  2225.                                                                 End,
  2226.                                                             Child,HGroup,
  2227.                                                                 Child,BT_Use=SimpleButton(glstr(MSG_Use)),
  2228.                                                                 Child,BT_Save=SimpleButton(glstr(MSG_Save)),
  2229.                                                                 Child,BT_Cancel=SimpleButton(glstr(MSG_Cancel)),
  2230.                                                                 End,
  2231.                                                             End,
  2232.                                                         End,
  2233.                                                     SubWindow,
  2234.                                                         WI_Program=WindowObject,
  2235.                                                         MUIA_Window_Title,glstr(MSG_ProgramWindowTitle),
  2236.                                                         MUIA_Window_ID,MAKE_ID('P','R','O','G'),
  2237.                                                         WindowContents,VGroup,
  2238.                                                             MUIA_Font,(customfonts)?(ULONG)normalfont:MUIV_Font_Normal,
  2239.                                                             MUIA_Background,MUII_WindowBack,
  2240.                                                             Child,HGroup,
  2241.                                                                 Child,VGroup,
  2242.                                                                     Child,TextObject,
  2243.                                                                         MUIA_Font,(customfonts)?(ULONG)titlefont:MUIV_Font_Title,
  2244.                                                                         MUIA_Text_Contents,glstr(MSG_TitleList),
  2245.                                                                         MUIA_Text_PreParse,"\33c",
  2246.                                                                         End,
  2247.                                                                     Child,LV_PList=ListviewObject,
  2248.                                                                         MUIA_Listview_DragType,MUIV_Listview_DragType_Immediate,
  2249.                                                                         MUIA_Listview_List,LI_PList=ListObject,
  2250.                                                                             MUIA_Font,(customfonts)?(ULONG)listfont:MUIV_Font_List,
  2251.                                                                             InputListFrame,
  2252.                                                                             MUIA_ShortHelp,glstr(MSG_HelpPTitles),
  2253.                                                                             MUIA_List_ConstructHook,MUIV_List_ConstructHook_String,
  2254.                                                                             MUIA_List_DestructHook,MUIV_List_DestructHook_String,
  2255.                                                                             MUIA_Background,MUII_ListBack,
  2256.                                                                             End,
  2257.                                                                         End,
  2258.                                                                     End,
  2259.                                                                 Child,VGroup,
  2260.                                                                     MUIA_Weight,0,
  2261.                                                                     Child,VSpace(0),
  2262.                                                                     Child,BT_PNew=SimpleButton(glstr(MSG_New)),
  2263.                                                                     Child,BT_PDelete=SimpleButton(glstr(MSG_Delete)),
  2264.                                                                     Child,BT_PTop=SimpleButton(glstr(MSG_Top)),
  2265.                                                                     Child,BT_PUp=SimpleButton(glstr(MSG_Up)),
  2266.                                                                     Child,BT_PDown=SimpleButton(glstr(MSG_Down)),
  2267.                                                                     Child,BT_PBottom=SimpleButton(glstr(MSG_Bottom)),
  2268.                                                                     Child,VSpace(0),
  2269.                                                                     End,
  2270.                                                                 Child,VGroup,
  2271.                                                                     Child,TextObject,
  2272.                                                                         MUIA_Font,(customfonts)?(ULONG)titlefont:MUIV_Font_Title,
  2273.                                                                         MUIA_Text_Contents,glstr(MSG_ProgramList),
  2274.                                                                         MUIA_Text_PreParse,"\33c",
  2275.                                                                         End,
  2276.                                                                     Child,LV_Program=ListviewObject,
  2277.                                                                         MUIA_Listview_DragType,MUIV_Listview_DragType_Immediate,
  2278.                                                                         MUIA_Listview_List,NewObject(CL_ProgramList->mcc_Class,NULL,
  2279.                                                                             MUIA_Font,(customfonts)?(ULONG)listfont:MUIV_Font_List,
  2280.                                                                             InputListFrame,
  2281.                                                                             MUIA_List_DragSortable,TRUE,
  2282.                                                                             MUIA_ShortHelp,glstr(MSG_HelpProgramList),
  2283.                                                                             MUIA_List_ConstructHook,MUIV_List_ConstructHook_String,
  2284.                                                                             MUIA_List_DestructHook,MUIV_List_DestructHook_String,
  2285.                                                                             MUIA_Background,MUII_ListBack,
  2286.                                                                             TAG_DONE),
  2287.                                                                         End,
  2288.                                                                     End,
  2289.                                                                 End,
  2290.                                                             Child,HGroup,
  2291.                                                                 Child,BT_PUse=SimpleButton(glstr(MSG_Use)),
  2292.                                                                 Child,BT_PSave=SimpleButton(glstr(MSG_Save)),
  2293.                                                                 Child,BT_PCancel=SimpleButton(glstr(MSG_Cancel)),
  2294.                                                                 End,
  2295.                                                             End,
  2296.                                                         End,
  2297.                                                     End;
  2298.                                             }
  2299.                                             else
  2300.                                             {
  2301.                                                 errorstr=glstr(MSG_FailApplication);
  2302.                                             }
  2303.  
  2304.                                             if(AP_SCDP)
  2305.                                             {
  2306.                                                 SetUpHotKeys();
  2307.  
  2308.                                                 if(popupflag==0)
  2309.                                                     set(AP_SCDP,MUIA_Application_Iconified,TRUE);
  2310.                                                 if(popupflag==1)
  2311.                                                     set(AP_SCDP,MUIA_Application_Iconified,FALSE);
  2312.  
  2313.                                                 set(BT_ProgramR,MUIA_ShortHelp,glstr(MSG_HelpProgramR));
  2314.                                                 set(BT_List,MUIA_ShortHelp,glstr(MSG_HelpList));
  2315.                                                 set(BT_Use,MUIA_ShortHelp,glstr(MSG_HelpUse));
  2316.                                                 set(BT_Save,MUIA_ShortHelp,glstr(MSG_HelpSave));
  2317.                                                 set(BT_Cancel,MUIA_ShortHelp,glstr(MSG_HelpCancel));
  2318.                                                 set(BT_PUse,MUIA_ShortHelp,glstr(MSG_HelpUse));
  2319.                                                 set(BT_PSave,MUIA_ShortHelp,glstr(MSG_HelpSave));
  2320.                                                 set(BT_PCancel,MUIA_ShortHelp,glstr(MSG_HelpCancel));
  2321.                                                 set(BT_PNew,MUIA_ShortHelp,glstr(MSG_HelpNew));
  2322.                                                 set(BT_PDelete,MUIA_ShortHelp,glstr(MSG_HelpDelete));
  2323.                                                 set(BT_PTop,MUIA_ShortHelp,glstr(MSG_HelpTop));
  2324.                                                 set(BT_PUp,MUIA_ShortHelp,glstr(MSG_HelpUp));
  2325.                                                 set(BT_PDown,MUIA_ShortHelp,glstr(MSG_HelpDown));
  2326.                                                 set(BT_PBottom,MUIA_ShortHelp,glstr(MSG_HelpBottom));
  2327.  
  2328.                                                 DoMethod(WI_SCDP,MUIM_Notify,MUIA_Window_CloseRequest,TRUE,AP_SCDP,2,MUIM_Application_ReturnID,MUIV_Application_ReturnID_Quit);
  2329.                                                 DoMethod(WI_List,MUIM_Window_SetCycleChain,ST_Artist,ST_CDTitle,ST_Title,CH_AutoPlay,CH_AutoProgram,CH_AutoShuffle,CH_AutoRepeat,BT_Use,BT_Save,BT_Cancel,NULL);
  2330.                                                 DoMethod(WI_Program,MUIM_Window_SetCycleChain,LV_PList,BT_PNew,BT_PDelete,BT_PTop,BT_PUp,BT_PDown,BT_PBottom,LV_Program,BT_PUse,BT_PSave,BT_PCancel,NULL);
  2331.  
  2332.                                                 DoMethod(BT_Shuffle,MUIM_Notify,MUIA_Selected,TRUE,BT_ProgramL,3,MUIM_Set,MUIA_Selected,FALSE);
  2333.                                                 DoMethod(BT_ProgramL,MUIM_Notify,MUIA_Selected,TRUE,BT_Shuffle,3,MUIM_Set,MUIA_Selected,FALSE);
  2334.                                                 DoMethod(CH_AutoShuffle,MUIM_Notify,MUIA_Selected,TRUE,CH_AutoProgram,3,MUIM_Set,MUIA_Selected,FALSE);
  2335.                                                 DoMethod(CH_AutoProgram,MUIM_Notify,MUIA_Selected,TRUE,CH_AutoShuffle,3,MUIM_Set,MUIA_Selected,FALSE);
  2336.  
  2337.                                                 DoMethod(BT_List,MUIM_Notify,MUIA_Selected,FALSE,AP_SCDP,2,MUIM_Application_ReturnID,ID_List);
  2338.                                                 DoMethod(BT_ProgramR,MUIM_Notify,MUIA_Selected,FALSE,AP_SCDP,2,MUIM_Application_ReturnID,ID_ProgramR);
  2339.                                                 DoMethod(BT_Play,MUIM_Notify,MUIA_Selected,FALSE,AP_SCDP,2,MUIM_Application_ReturnID,ID_Play);
  2340.                                                 DoMethod(BT_Pause,MUIM_Notify,MUIA_Selected,FALSE,AP_SCDP,2,MUIM_Application_ReturnID,ID_Pause);
  2341.                                                 DoMethod(BT_Stop,MUIM_Notify,MUIA_Selected,FALSE,AP_SCDP,2,MUIM_Application_ReturnID,ID_Stop);
  2342.                                                 DoMethod(BT_Previous,MUIM_Notify,MUIA_Selected,FALSE,AP_SCDP,2,MUIM_Application_ReturnID,ID_Previous);
  2343.                                                 DoMethod(BT_Next,MUIM_Notify,MUIA_Selected,FALSE,AP_SCDP,2,MUIM_Application_ReturnID,ID_Next);
  2344.                                                 DoMethod(BT_Rewind,MUIM_Notify,MUIA_Selected,FALSE,AP_SCDP,2,MUIM_Application_ReturnID,ID_Rewind);
  2345.                                                 DoMethod(BT_FastForward,MUIM_Notify,MUIA_Selected,FALSE,AP_SCDP,2,MUIM_Application_ReturnID,ID_FastForward);
  2346.                                                 DoMethod(BT_Eject,MUIM_Notify,MUIA_Selected,FALSE,AP_SCDP,2,MUIM_Application_ReturnID,ID_Eject);
  2347.                                                 DoMethod(BT_ProgramL,MUIM_Notify,MUIA_Selected,MUIV_EveryTime,AP_SCDP,2,MUIM_Application_ReturnID,ID_ProgramL);
  2348.                                                 DoMethod(BT_Shuffle,MUIM_Notify,MUIA_Selected,MUIV_EveryTime,AP_SCDP,2,MUIM_Application_ReturnID,ID_Shuffle);
  2349.                                                 DoMethod(SL_Volume,MUIM_Notify,MUIA_Slider_Level,MUIV_EveryTime,AP_SCDP,2,MUIM_Application_ReturnID,ID_Volume);
  2350.  
  2351.                                                 DoMethod(BT_Use,MUIM_Notify,MUIA_Selected,FALSE,AP_SCDP,2,MUIM_Application_ReturnID,ID_Use);
  2352.                                                 DoMethod(BT_Save,MUIM_Notify,MUIA_Selected,FALSE,AP_SCDP,2,MUIM_Application_ReturnID,ID_Save);
  2353.                                                 DoMethod(BT_Cancel,MUIM_Notify,MUIA_Selected,FALSE,WI_List,3,MUIM_Set,MUIA_Window_Open,FALSE);
  2354.                                                 DoMethod(WI_List,MUIM_Notify,MUIA_Window_CloseRequest,TRUE,WI_List,3,MUIM_Set,MUIA_Window_Open,FALSE);
  2355.  
  2356.                                                 DoMethod(LV_TrackSelect,MUIM_Notify,MUIA_Listview_DoubleClick,TRUE,AP_SCDP,2,MUIM_Application_ReturnID,ID_TrackSelect);
  2357.                                                 DoMethod(LV_ProgramSelect,MUIM_Notify,MUIA_Listview_DoubleClick,TRUE,AP_SCDP,2,MUIM_Application_ReturnID,ID_ProgramSelect);
  2358.                                                 DoMethod(LV_TitleList,MUIM_Notify,MUIA_List_Active,MUIV_EveryTime,AP_SCDP,2,MUIM_Application_ReturnID,ID_ChangeActive);
  2359.                                                 DoMethod(ST_Title,MUIM_Notify,MUIA_String_Acknowledge,MUIV_EveryTime,AP_SCDP,2,MUIM_Application_ReturnID,ID_Confirm);
  2360.                                                 DoMethod(ST_Title,MUIM_Notify,MUIA_String_Acknowledge,MUIV_EveryTime,WI_List,3,MUIM_Set,MUIA_Window_ActiveObject,ST_Title);
  2361.                                                 DoMethod(ST_Artist,MUIM_Notify,MUIA_String_Acknowledge,MUIV_EveryTime,WI_List,3,MUIM_Set,MUIA_Window_ActiveObject,ST_CDTitle);
  2362.                                                 DoMethod(ST_CDTitle,MUIM_Notify,MUIA_String_Acknowledge,MUIV_EveryTime,WI_List,3,MUIM_Set,MUIA_Window_ActiveObject,ST_Title);
  2363.  
  2364.                                                 DoMethod(BT_PUse,MUIM_Notify,MUIA_Selected,FALSE,AP_SCDP,2,MUIM_Application_ReturnID,ID_PUse);
  2365.                                                 DoMethod(BT_PSave,MUIM_Notify,MUIA_Selected,FALSE,AP_SCDP,2,MUIM_Application_ReturnID,ID_PSave);
  2366.                                                 DoMethod(BT_PCancel,MUIM_Notify,MUIA_Selected,FALSE,WI_Program,3,MUIM_Set,MUIA_Window_Open,FALSE);
  2367.                                                 DoMethod(WI_Program,MUIM_Notify,MUIA_Window_CloseRequest,TRUE,WI_Program,3,MUIM_Set,MUIA_Window_Open,FALSE);
  2368.                                                 DoMethod(LV_PList,MUIM_Notify,MUIA_Listview_DoubleClick,MUIV_EveryTime,AP_SCDP,2,MUIM_Application_ReturnID,ID_PInsert);
  2369.                                                 DoMethod(BT_PNew,MUIM_Notify,MUIA_Selected,FALSE,LV_Program,1,MUIM_List_Clear);
  2370.                                                 DoMethod(BT_PDelete,MUIM_Notify,MUIA_Selected,FALSE,LV_Program,2,MUIM_List_Remove,MUIV_List_Remove_Active);
  2371.                                                 DoMethod(BT_PTop,MUIM_Notify,MUIA_Selected,FALSE,LV_Program,3,MUIM_List_Move,MUIV_List_Move_Active,MUIV_List_Move_Top);
  2372.                                                 DoMethod(BT_PTop,MUIM_Notify,MUIA_Selected,FALSE,LV_Program,3,MUIM_Set,MUIA_List_Active,MUIV_List_Active_Top);
  2373.                                                 DoMethod(BT_PUp,MUIM_Notify,MUIA_Selected,FALSE,LV_Program,3,MUIM_List_Move,MUIV_List_Move_Active,MUIV_List_Move_Previous);
  2374.                                                 DoMethod(BT_PUp,MUIM_Notify,MUIA_Selected,FALSE,LV_Program,3,MUIM_Set,MUIA_List_Active,MUIV_List_Active_Up);
  2375.                                                 DoMethod(BT_PDown,MUIM_Notify,MUIA_Selected,FALSE,LV_Program,3,MUIM_List_Move,MUIV_List_Move_Active,MUIV_List_Move_Next);
  2376.                                                 DoMethod(BT_PDown,MUIM_Notify,MUIA_Selected,FALSE,LV_Program,3,MUIM_Set,MUIA_List_Active,MUIV_List_Active_Down);
  2377.                                                 DoMethod(BT_PBottom,MUIM_Notify,MUIA_Selected,FALSE,LV_Program,3,MUIM_List_Move,MUIV_List_Move_Active,MUIV_List_Move_Bottom);
  2378.                                                 DoMethod(BT_PBottom,MUIM_Notify,MUIA_Selected,FALSE,LV_Program,3,MUIM_Set,MUIA_List_Active,MUIV_List_Active_Bottom);
  2379.                                                 DoMethod(LV_Program,MUIM_Notify,MUIA_Listview_DoubleClick,MUIV_EveryTime,LV_Program,2,MUIM_List_Remove,MUIV_List_Remove_Active);
  2380.  
  2381.                                                 for(a=0;a<buttonscriptsno;a++)
  2382.                                                     DoMethod(BT_A[a],MUIM_Notify,MUIA_Selected,FALSE,AP_SCDP,2,MUIM_Application_ReturnID,ID_A1+a);
  2383.  
  2384.                                                 set(BT_List,MUIA_Disabled,TRUE);
  2385.                                                 set(BT_ProgramR,MUIA_Disabled,TRUE);
  2386.                                                 set(WI_SCDP,MUIA_Window_Open,TRUE);
  2387.  
  2388.                                                 if(!volumecontrol)
  2389.                                                     set(SL_Volume,MUIA_Disabled,TRUE);
  2390.  
  2391.                                                 /*set(WI_Program,MUIA_Window_Open,TRUE);*/
  2392.  
  2393.                                                 i=vamos=TRUE;
  2394.                                                 signals=0;
  2395.                                                 CDSetVolume(-1);
  2396.                                                 
  2397.                                                 StartARexx();
  2398.  
  2399.                                                 if(*scriptonstart)
  2400.                                                 {
  2401.                                                     LaunchARexxScript(scriptonstart);
  2402.                                                 }
  2403.  
  2404.                                                 while(i || rxmsgs)
  2405.                                                 {
  2406.                                                     if(signals&(1<<tmsgport->mp_SigBit))
  2407.                                                     {
  2408.                                                         struct RexxMsg *rxmsg=NULL;
  2409.                                                         
  2410.                                                         GetMsg(tmsgport);
  2411.  
  2412.                                                         if(rexxok && rxmsgs)
  2413.                                                         {
  2414.                                                             while(rxmsg=GetMsg(rxmp))
  2415.                                                             {
  2416.                                                                 ClearRexxMsg(rxmsg,1);
  2417.                                                                 DeleteRexxMsg(rxmsg);
  2418.                                                                 rxmsgs--;
  2419.                                                             }
  2420.                                                         }
  2421.                                                         
  2422.                                                         if(delayedplay)
  2423.                                                         {
  2424.                                                             actuate=0;
  2425.                                                             delayedplay--;
  2426.                                                             if(!delayedplay)
  2427.                                                             {
  2428.                                                                 int qq;
  2429.                                                                 
  2430.                                                                 get(CH_AutoPlay,MUIA_Selected,&qq);
  2431.                                                                 
  2432.                                                                 if(qq)
  2433.                                                                 {
  2434.                                                                     DoMethod(AP_SCDP,MUIM_Application_ReturnID,ID_Play);
  2435.                                                                     skip=3;
  2436.                                                                 }
  2437.                                                             }
  2438.                                                         }
  2439.                                                         
  2440.                                                         if(actuate)
  2441.                                                         {
  2442.                                                             get(BT_Repeat,MUIA_Selected,&a);
  2443.                                                             if(pstatus==NORMAL)
  2444.                                                             {
  2445.                                                                 if(a)
  2446.                                                                 {
  2447.                                                                     track=1;
  2448.                                                                     while((TOCflags[track-1]&1) && track<=TOClength)
  2449.                                                                         track++;
  2450.                                                                     if(track>TOClength)
  2451.                                                                     {
  2452.                                                                         CDStop();
  2453.                                                                         track=0;
  2454.                                                                     }
  2455.                                                                     else
  2456.                                                                     {
  2457.                                                                         CDPlay(TOCaddr[track-1],TOCaddr[TOClength]-TOCaddr[track-1]);
  2458.                                                                         CDGetPos(FALSE);
  2459.                                                                     }
  2460.                                                                 }
  2461.                                                                 else
  2462.                                                                 {
  2463.                                                                     CDStop();
  2464.                                                                     track=0;
  2465.                                                                 }
  2466.                                                             }
  2467.                                                             else
  2468.                                                             {
  2469.                                                                 pactual++;
  2470.                                                                 if(!programmed[pactual-1] && a)
  2471.                                                                 {
  2472.                                                                     pactual=1;
  2473.                                                                     if(pstatus==SHUFFLE)
  2474.                                                                         DoShuffle();
  2475.                                                                 }
  2476.                                                                 if(!programmed[pactual-1])
  2477.                                                                 {
  2478.                                                                     CDStop();
  2479.                                                                     track=0;
  2480.                                                                 }
  2481.                                                                 else
  2482.                                                                 {
  2483.                                                                     track=programmed[pactual-1];
  2484.                                                                     CDPlay(TOCaddr[track-1],TOCaddr[TOClength]-TOCaddr[track-1]);
  2485.                                                                 }
  2486.                                                             }
  2487.                                                             actuate=0;
  2488.                                                         }
  2489.  
  2490.                                                         CDGetPos(TRUE);
  2491.                                                         if(useraction==-1)
  2492.                                                             useraction=0;
  2493.                                                     }
  2494.  
  2495.                                                     b=DoMethod(AP_SCDP,MUIM_Application_Input,&signals);
  2496.                                                     if((b==ID_Next || b==ID_Previous) && status!=PLAYING)
  2497.                                                         b=ID_Play;
  2498.                                                     switch(b)
  2499.                                                     {
  2500.                                                         case MEN_QUIT:
  2501.                                                         case MUIV_Application_ReturnID_Quit:
  2502.                                                             if(*scriptonquit && !quitting)
  2503.                                                             {
  2504.                                                                 LaunchARexxScript(scriptonquit);
  2505.                                                             }
  2506.                                                             i=FALSE;
  2507.                                                             quitting=TRUE;
  2508.                                                             break;
  2509.                                                         case MEN_ABOUT:
  2510.                                                             MUI_Request(AP_SCDP,WI_SCDP,0,NULL,glstr(MSG_AboutGadget),glstr(MSG_AboutText));
  2511.                                                             break;
  2512.                                                         case MEN_ABOUTMUI:
  2513.                                                             if(!WI_AboutMUI)
  2514.                                                                 WI_AboutMUI=AboutmuiObject,
  2515.                                                                     MUIA_Window_RefWindow,WI_SCDP,
  2516.                                                                     MUIA_Aboutmui_Application,AP_SCDP,
  2517.                                                                     End;
  2518.                                                             if(WI_AboutMUI)
  2519.                                                                 set(WI_AboutMUI,MUIA_Window_Open,TRUE);
  2520.                                                             else
  2521.                                                                 DisplayBeep(0);
  2522.                                                             break;
  2523.                                                         case MEN_MUI:
  2524.                                                             DoMethod(AP_SCDP,MUIM_Application_OpenConfigWindow,0);
  2525.                                                             break;
  2526.                                                         case MEN_EXECUTE:
  2527.                                                             {
  2528.                                                                 struct FileRequester *fr;
  2529.                                                                 char buff[256];
  2530.                                                                 
  2531.                                                                 useraction=1;
  2532.                                                                 
  2533.                                                                 fr=AllocAslRequestTags(ASL_FileRequest,ASLFR_TitleText,glstr(MSG_SelectARexx),ASLFR_InitialDrawer,"Rexx",ASLFR_InitialPattern,"#?.scdp",ASLFR_DoPatterns,TRUE,ASLFR_RejectIcons,TRUE);
  2534.                                                                 if(fr)
  2535.                                                                 {
  2536.                                                                     set(AP_SCDP,MUIA_Application_Sleep,TRUE);
  2537.                                                                     if(AslRequest(fr,NULL))
  2538.                                                                     {
  2539.                                                                         strcpy(buff,fr->fr_Drawer);
  2540.                                                                         if(strlen(buff) && buff[strlen(buff)-1]!='/' && buff[strlen(buff)-1]!=':')
  2541.                                                                         {
  2542.                                                                             strcat(buff,"/");
  2543.                                                                         }
  2544.                                                                         strcat(buff,fr->fr_File);
  2545.                                                                         LaunchARexxScript(buff);
  2546.                                                                     }
  2547.                                                                     set(AP_SCDP,MUIA_Application_Sleep,FALSE);
  2548.                                                                     FreeAslRequest(fr);
  2549.                                                                 }
  2550.                                                             }
  2551.                                                             break;
  2552.                                                         case MEN_A1:
  2553.                                                         case MEN_A2:
  2554.                                                         case MEN_A3:
  2555.                                                         case MEN_A4:
  2556.                                                         case MEN_A5:
  2557.                                                         case MEN_A6:
  2558.                                                         case MEN_A7:
  2559.                                                         case MEN_A8:
  2560.                                                             useraction=1;
  2561.                                                             LaunchARexxScript(menuscripts[b-MEN_A1]);
  2562.                                                             break;
  2563.                                                         case ID_A1:
  2564.                                                         case ID_A2:
  2565.                                                         case ID_A3:
  2566.                                                         case ID_A4:
  2567.                                                         case ID_A5:
  2568.                                                         case ID_A6:
  2569.                                                         case ID_A7:
  2570.                                                         case ID_A8:
  2571.                                                             useraction=1;
  2572.                                                             LaunchARexxScript(buttonscripts[b-ID_A1]);
  2573.                                                             break;
  2574.                                                         case ID_Volume:
  2575.                                                             get(SL_Volume,MUIA_Slider_Level,&a);
  2576.                                                             CDSetVolume(a);
  2577.                                                             break;
  2578.                                                         case ID_Play:
  2579.                                                             useraction=(useraction!=-1);
  2580.                                                             switch(pstatus)
  2581.                                                             {
  2582.                                                                 case NORMAL:
  2583.                                                                     switch(status)
  2584.                                                                     {
  2585.                                                                         case STOPPED:
  2586.                                                                             track=1;
  2587.                                                                             while((TOCflags[track-1]&1) && track<=TOClength)
  2588.                                                                                 track++;
  2589.                                                                             if(track>TOClength)
  2590.                                                                             {
  2591.                                                                                 CDStop();
  2592.                                                                                 track=0;
  2593.                                                                             }
  2594.                                                                             else
  2595.                                                                             {
  2596.                                                                                 CDPlay(TOCaddr[track-1],TOCaddr[TOClength]-TOCaddr[track-1]);
  2597.                                                                                 CDGetPos(FALSE);
  2598.                                                                             }
  2599.                                                                             break;
  2600.                                                                         case PAUSED:
  2601.                                                                             CDResume();
  2602.                                                                             break;
  2603.                                                                     }
  2604.                                                                     break;
  2605.                                                                 case SHUFFLE:
  2606.                                                                     switch(status)
  2607.                                                                     {
  2608.                                                                         case STOPPED:
  2609.                                                                             DoShuffle();
  2610.                                                                             if(programmed[0])
  2611.                                                                             {
  2612.                                                                                 a=programmed[0];
  2613.                                                                                 pactual=1;
  2614.                                                                                 CDPlay(TOCaddr[a-1],TOCaddr[TOClength]-TOCaddr[a-1]);
  2615.                                                                                 CDGetPos(FALSE);
  2616.                                                                             }
  2617.                                                                             break;
  2618.                                                                         case PAUSED:
  2619.                                                                             CDResume();
  2620.                                                                             break;
  2621.                                                                     }
  2622.                                                                     break;
  2623.                                                                 case PROGRAM:
  2624.                                                                     switch(status)
  2625.                                                                     {
  2626.                                                                         case STOPPED:
  2627.                                                                             DoProgram();
  2628.                                                                             if(programmed[0])
  2629.                                                                             {
  2630.                                                                                 a=programmed[0];
  2631.                                                                                 pactual=1;
  2632.                                                                                 CDPlay(TOCaddr[a-1],TOCaddr[TOClength]-TOCaddr[a-1]);
  2633.                                                                                 CDGetPos(FALSE);
  2634.                                                                             }
  2635.                                                                             break;
  2636.                                                                         case PAUSED:
  2637.                                                                             CDResume();
  2638.                                                                             break;
  2639.                                                                     }
  2640.                                                                     break;
  2641.                                                             }
  2642.                                                             break;
  2643.                                                         case ID_Eject:
  2644.                                                             useraction=1;
  2645.                                                             if(trayout)
  2646.                                                             {
  2647.                                                                 CDLoad();
  2648.                                                                 trayout=FALSE;
  2649.                                                             }
  2650.                                                             else
  2651.                                                             {
  2652.                                                                 CDEject();
  2653.                                                                 trayout=TRUE;
  2654.                                                             }
  2655.                                                             break;
  2656.                                                         case ID_Pause:
  2657.                                                             useraction=(useraction!=-1);
  2658.                                                             if(status==PAUSED)
  2659.                                                                 CDResume();
  2660.                                                             else
  2661.                                                                 CDPause();
  2662.                                                             break;
  2663.                                                         case ID_Stop:
  2664.                                                             useraction=(useraction!=-1);
  2665.                                                             CDStop();
  2666.                                                             break;
  2667.                                                         case ID_Rewind:
  2668.                                                             useraction=(useraction!=-1);
  2669.                                                             if(status==PLAYING && actualindex<14400000 && actualindex>(75*5))
  2670.                                                             {
  2671.                                                                 CDGetPos(FALSE);
  2672.                                                                 totalindex-=(75*5);
  2673.                                                                 CDPlay(totalindex,TOCaddr[TOClength]-totalindex);
  2674.                                                                 CDGetPos(FALSE);
  2675.                                                             }
  2676.                                                             break;
  2677.                                                         case ID_FastForward:
  2678.                                                             useraction=(useraction!=-1);
  2679.                                                             if(status==PLAYING && totalindex<TOCaddr[track]-(75*5) && actualindex>0)
  2680.                                                             {
  2681.                                                                 CDGetPos(FALSE);
  2682.                                                                 totalindex+=(75*5);
  2683.                                                                 CDPlay(totalindex,TOCaddr[TOClength]-totalindex);
  2684.                                                                 CDGetPos(FALSE);
  2685.                                                             }
  2686.                                                             break;
  2687.                                                         case ID_Previous:
  2688.                                                             useraction=(useraction!=-1);
  2689.                                                             if(status==PLAYING)
  2690.                                                             {
  2691.                                                                 CDGetPos(FALSE);
  2692.                                                                 if(totalindex-TOCaddr[track-1]>(75*5))
  2693.                                                                 {
  2694.                                                                     CDPlay(TOCaddr[track-1],TOCaddr[TOClength]-TOCaddr[track-1]);
  2695.                                                                 }
  2696.                                                                 else
  2697.                                                                 {
  2698.                                                                     switch(pstatus)
  2699.                                                                     {
  2700.                                                                         case NORMAL:
  2701.                                                                             if(onevalid)
  2702.                                                                             {
  2703.                                                                                 track--;
  2704.                                                                                 if(!track)
  2705.                                                                                     track=TOClength;
  2706.                                                                                 while(TOCflags[track-1])
  2707.                                                                                 {
  2708.                                                                                     track--;
  2709.                                                                                     if(!track)
  2710.                                                                                         track=TOClength;
  2711.                                                                                 }
  2712.                                                                                 CDPlay(TOCaddr[track-1],TOCaddr[TOClength]-TOCaddr[track-1]);
  2713.                                                                             }
  2714.                                                                             break;
  2715.                                                                         default:
  2716.                                                                             if(onevalid && pactual>1)
  2717.                                                                             {
  2718.                                                                                 pactual--;
  2719.                                                                                 track=programmed[pactual-1];
  2720.                                                                                 CDPlay(TOCaddr[track-1],TOCaddr[track]-TOCaddr[track-1]);
  2721.                                                                             }
  2722.                                                                             break;
  2723.                                                                     }
  2724.                                                                 }
  2725.                                                                 CDGetPos(FALSE);
  2726.                                                             }
  2727.                                                             break;
  2728.                                                         case ID_Next:
  2729.                                                             useraction=(useraction!=-1);
  2730.                                                             if(status==PLAYING)
  2731.                                                             {
  2732.                                                                 CDGetPos(FALSE);
  2733.                                                                 {
  2734.                                                                     switch(pstatus)
  2735.                                                                     {
  2736.                                                                         case NORMAL:
  2737.                                                                             if(onevalid)
  2738.                                                                             {
  2739.                                                                                 track++;
  2740.                                                                                 if(track>TOClength)
  2741.                                                                                     track=1;
  2742.                                                                                 while(TOCflags[track-1])
  2743.                                                                                 {
  2744.                                                                                     track++;
  2745.                                                                                     if(track>TOClength)
  2746.                                                                                         track=1;
  2747.                                                                                 }
  2748.                                                                                 CDPlay(TOCaddr[track-1],TOCaddr[TOClength]-TOCaddr[track-1]);
  2749.                                                                             }
  2750.                                                                             break;
  2751.                                                                         default:
  2752.                                                                             if(onevalid && programmed[pactual])
  2753.                                                                             {
  2754.                                                                                 pactual++;
  2755.                                                                                 track=programmed[pactual-1];
  2756.                                                                                 CDPlay(TOCaddr[track-1],TOCaddr[track]-TOCaddr[track-1]);
  2757.                                                                             }
  2758.                                                                             break;
  2759.                                                                     }
  2760.                                                                 }
  2761.                                                                 CDGetPos(FALSE);
  2762.                                                             }
  2763.                                                             break;
  2764.                                                         case ID_TrackSelect:
  2765.                                                             useraction=1;
  2766.                                                             get(LV_TrackSelect,MUIA_List_Active,&a);
  2767.                                                             if(a>=0 && a<TOClength && !TOCflags[a])
  2768.                                                             {
  2769.                                                                 pstatus=NORMAL;
  2770.                                                                 set(BT_ProgramL,MUIA_Selected,FALSE);
  2771.                                                                 set(BT_Shuffle,MUIA_Selected,FALSE);
  2772.                                                                 track=a+1;
  2773.                                                                 CDPlay(TOCaddr[track-1],TOCaddr[TOClength]-TOCaddr[track-1]);
  2774.                                                                 CDGetPos(FALSE);
  2775.                                                             }
  2776.                                                             break;
  2777.                                                         case ID_ProgramSelect:
  2778.                                                             useraction=1;
  2779.                                                             set(BT_ProgramL,MUIA_Selected,TRUE);
  2780.                                                             if(pstatus!=PROGRAM)
  2781.                                                             {
  2782.                                                                 CDStop();
  2783.                                                             }
  2784.                                                             pstatus=PROGRAM;
  2785.                                                             DoProgram();
  2786.                                                             if(programmed[0])
  2787.                                                             {
  2788.                                                                 get(LV_ProgramSelect,MUIA_List_Active,&a);
  2789.                                                                 CDPlay(TOCaddr[programmed[a]-1],TOCaddr[TOClength]-TOCaddr[programmed[a]-1]);
  2790.                                                                 pactual=a+1;
  2791.                                                             }
  2792.                                                             else if(status!=STOPPED)
  2793.                                                                 CDStop();
  2794.                                                             break;
  2795.                                                         case ID_ProgramL:
  2796.                                                             useraction=(useraction!=-1);
  2797.                                                             get(BT_ProgramL,MUIA_Selected,&a);
  2798.                                                             if(a)
  2799.                                                             {
  2800.                                                                 pstatus=PROGRAM;
  2801.                                                                 DoProgram();
  2802.                                                                 if(status==PLAYING && programmed[0])
  2803.                                                                 {
  2804.                                                                     a=programmed[0];
  2805.  
  2806.                                                                     CDPlay(TOCaddr[a-1],TOCaddr[TOClength]-TOCaddr[a-1]);
  2807.                                                                     pactual=1;
  2808.                                                                 }
  2809.                                                                 else if(status!=STOPPED)
  2810.                                                                     CDStop();
  2811.                                                             }
  2812.                                                             else
  2813.                                                                 if(pstatus==PROGRAM)
  2814.                                                                     pstatus=NORMAL;
  2815.                                                             break;
  2816.                                                         case ID_Shuffle:
  2817.                                                             useraction=(useraction!=-1);
  2818.                                                             get(BT_Shuffle,MUIA_Selected,&a);
  2819.                                                             if(a)
  2820.                                                             {
  2821.                                                                 pstatus=SHUFFLE;
  2822.                                                                 DoShuffle();
  2823.                                                                 if(status==PLAYING && programmed[0])
  2824.                                                                 {
  2825.                                                                     a=programmed[0];
  2826.  
  2827.                                                                     CDPlay(TOCaddr[a-1],TOCaddr[a]-TOCaddr[a-1]);
  2828.                                                                     pactual=1;
  2829.                                                                 }
  2830.                                                                 else if(status!=STOPPED)
  2831.                                                                     CDStop();
  2832.                                                             }
  2833.                                                             else
  2834.                                                                 if(pstatus==SHUFFLE)
  2835.                                                                     pstatus=NORMAL;
  2836.                                                             break;
  2837.                                                         case ID_List:
  2838.                                                             FillList();
  2839.                                                             break;
  2840.                                                         case ID_ChangeActive:
  2841.                                                             DoMethod(LV_TitleList,MUIM_List_GetEntry,MUIV_List_GetEntry_Active,&strptr);
  2842.                                                             if(strptr)
  2843.                                                             {
  2844.                                                                 strcpy(buff,strptr);
  2845.                                                                 set(ST_Title,MUIA_String_Contents,buff+4);
  2846.                                                             }
  2847.                                                             break;
  2848.                                                         case ID_Confirm:
  2849.                                                             get(ST_Title,MUIA_String_Contents,&strptr);
  2850.                                                             get(LV_TitleList,MUIA_List_Active,&a);
  2851.                                                             if(a>=0 && a<TOClength)
  2852.                                                             {
  2853.                                                                 sprintf(buff,"%02d: %s",a+1,strptr);
  2854.                                                                 set(LV_TitleList,MUIA_List_Quiet,TRUE);
  2855.                                                                 DoMethod(LV_TitleList,MUIM_List_Remove,a);
  2856.                                                                 DoMethod(LV_TitleList,MUIM_List_InsertSingle,buff,a);
  2857.                                                                 set(LV_TitleList,MUIA_List_Quiet,FALSE);
  2858.                                                             }
  2859.                                                             break;
  2860.                                                         case ID_RexxSave:
  2861.                                                             {
  2862.                                                                 FILE *f;
  2863.                                                                 int a,b,c,d;
  2864.                                                                 set(WI_List,MUIA_Window_Open,FALSE);
  2865.                                                                 sprintf(buff,"%s%s",diskspath,TOCCDID);
  2866.                                                                 if(f=fopen(buff,"w"))
  2867.                                                                 {
  2868.                                                                     fprintf(f,"%s\n%s\n",TOCCDartist,TOCCDtitle);
  2869.                                                                     for(a=0;a<TOClength;a++)
  2870.                                                                     {
  2871.                                                                         DoMethod(LV_TrackSelect,MUIM_List_GetEntry,a,&strptr);
  2872.                                                                         fprintf(f,"%s\n",((char *)strptr)+4);
  2873.                                                                     }
  2874.                                                                     get(CH_AutoPlay,MUIA_Selected,&a);
  2875.                                                                     get(CH_AutoProgram,MUIA_Selected,&b);
  2876.                                                                     get(CH_AutoShuffle,MUIA_Selected,&c);
  2877.                                                                     get(CH_AutoRepeat,MUIA_Selected,&d);
  2878.                                                                     fprintf(f,"*%c\n",'0'+(a)+(b<<1)+(c<<2)+(d<<3));
  2879.                                                                     fclose(f);
  2880.                                                                 }
  2881.                                                             }
  2882.                                                             break;
  2883.                                                         case ID_Save:
  2884.                                                             {
  2885.                                                                 FILE *f;
  2886.                                                                 char *s1, *s2;
  2887.                                                                 int a,b,c,d;
  2888.                                                                 sprintf(buff,"%s%s",diskspath,TOCCDID);
  2889.                                                                 if(f=fopen(buff,"w"))
  2890.                                                                 {
  2891.                                                                     get(ST_Artist,MUIA_String_Contents,&s1);
  2892.                                                                     get(ST_CDTitle,MUIA_String_Contents,&s2);
  2893.                                                                     fprintf(f,"%s\n%s\n",s1,s2);
  2894.                                                                     for(a=0;a<TOClength;a++)
  2895.                                                                     {
  2896.                                                                         DoMethod(LV_TitleList,MUIM_List_GetEntry,a,&strptr);
  2897.                                                                         fprintf(f,"%s\n",((char *)strptr)+4);
  2898.                                                                     }
  2899.                                                                     get(CH_AutoPlay,MUIA_Selected,&a);
  2900.                                                                     get(CH_AutoProgram,MUIA_Selected,&b);
  2901.                                                                     get(CH_AutoShuffle,MUIA_Selected,&c);
  2902.                                                                     get(CH_AutoRepeat,MUIA_Selected,&d);
  2903.                                                                     fprintf(f,"*%c\n",'0'+(a)+(b<<1)+(c<<2)+(d<<3));
  2904.                                                                     fclose(f);
  2905.                                                                 }
  2906.                                                             }
  2907.                                                         case ID_Use:
  2908.                                                             get(ST_Artist,MUIA_String_Contents,&strptr);
  2909.                                                             strcpy(TOCCDartist,strptr);
  2910.                                                             get(ST_CDTitle,MUIA_String_Contents,&strptr);
  2911.                                                             strcpy(TOCCDtitle,strptr);
  2912.                                                             set(LV_TrackSelect,MUIA_List_Quiet,TRUE);
  2913.                                                             DoMethod(LV_TrackSelect,MUIM_List_Clear);
  2914.                                                             set(LV_PList,MUIA_List_Quiet,TRUE);
  2915.                                                             DoMethod(LV_PList,MUIM_List_Clear);
  2916.                                                             for(a=0;a<TOClength;a++)
  2917.                                                             {
  2918.                                                                 DoMethod(LV_TitleList,MUIM_List_GetEntry,a,&strptr);
  2919.                                                                 DoMethod(LV_TrackSelect,MUIM_List_InsertSingle,strptr,MUIV_List_Insert_Bottom);
  2920.                                                                 DoMethod(LV_PList,MUIM_List_InsertSingle,strptr,MUIV_List_Insert_Bottom);
  2921.                                                             }
  2922.                                                             set(LV_TrackSelect,MUIA_List_Quiet,FALSE);
  2923.                                                             set(LV_PList,MUIA_List_Quiet,FALSE);
  2924.                                                             set(LV_Program,MUIA_List_Quiet,TRUE);
  2925.                                                             DoMethod(LV_Program,MUIM_List_Clear);
  2926.                                                             set(LV_ProgramSelect,MUIA_List_Quiet,TRUE);
  2927.                                                             DoMethod(LV_ProgramSelect,MUIM_List_Clear);
  2928.                                                             a=0;
  2929.                                                             while(pprog[a])
  2930.                                                             {
  2931.                                                                 DoMethod(LV_TrackSelect,MUIM_List_GetEntry,pprog[a]-1,&strptr);
  2932.                                                                 DoMethod(LV_Program,MUIM_List_InsertSingle,strptr,MUIV_List_Insert_Bottom);
  2933.                                                                 DoMethod(LV_ProgramSelect,MUIM_List_InsertSingle,strptr,MUIV_List_Insert_Bottom);
  2934.                                                                 a++;
  2935.                                                             }
  2936.                                                             set(LV_Program,MUIA_List_Quiet,FALSE);
  2937.                                                             set(LV_ProgramSelect,MUIA_List_Quiet,FALSE);
  2938.  
  2939.                                                             refresh=TRUE;
  2940.                                                             set(WI_List,MUIA_Window_Open,FALSE);
  2941.                                                             CDGetPos(FALSE);
  2942.                                                             break;
  2943.                                                         case ID_PInsert:
  2944.                                                             DoMethod(LV_PList,MUIM_List_GetEntry,MUIV_List_GetEntry_Active,&strptr);
  2945.                                                             if(strptr)
  2946.                                                             {
  2947.                                                                 DoMethod(LV_Program,MUIM_List_InsertSingle,strptr,MUIV_List_Insert_Bottom);
  2948.                                                             }
  2949.                                                             break;
  2950.                                                         case ID_ProgramR:
  2951.                                                             set(LV_Program,MUIA_List_Quiet,TRUE);
  2952.                                                             DoMethod(LV_Program,MUIM_List_Clear);
  2953.                                                             a=0;
  2954.                                                             while(pprog[a])
  2955.                                                             {
  2956.                                                                 DoMethod(LV_TrackSelect,MUIM_List_GetEntry,pprog[a]-1,&strptr);
  2957.                                                                 DoMethod(LV_Program,MUIM_List_InsertSingle,strptr,MUIV_List_Insert_Bottom);
  2958.                                                                 a++;
  2959.                                                             }
  2960.                                                             set(LV_Program,MUIA_List_Quiet,FALSE);
  2961.                                                             set(WI_Program,MUIA_Window_ActiveObject,LV_PList);
  2962.                                                             set(WI_Program,MUIA_Window_Open,TRUE);
  2963.                                                             break;
  2964.                                                         case ID_PUse:
  2965.                                                             useraction=1;
  2966.                                                             a=0;
  2967.                                                             do
  2968.                                                             {
  2969.                                                                 DoMethod(LV_Program,MUIM_List_GetEntry,a,&strptr);
  2970.                                                                 if(strptr)
  2971.                                                                 {
  2972.                                                                     pprog[a]=(strptr[0]-'0')*10+strptr[1]-'0';
  2973.                                                                     a++;
  2974.                                                                 }
  2975.                                                             }while(strptr);
  2976.                                                             pprog[a]=0;
  2977.                                                             set(LV_ProgramSelect,MUIA_List_Quiet,TRUE);
  2978.                                                             DoMethod(LV_ProgramSelect,MUIM_List_Clear);
  2979.                                                             a=0;
  2980.                                                             while(pprog[a])
  2981.                                                             {
  2982.                                                                 DoMethod(LV_TrackSelect,MUIM_List_GetEntry,pprog[a]-1,&strptr);
  2983.                                                                 DoMethod(LV_ProgramSelect,MUIM_List_InsertSingle,strptr,MUIV_List_Insert_Bottom);
  2984.                                                                 a++;
  2985.                                                             }
  2986.                                                             set(LV_ProgramSelect,MUIA_List_Quiet,FALSE);
  2987.  
  2988.                                                             set(WI_Program,MUIA_Window_Open,FALSE);
  2989.                                                             break;
  2990.                                                         case ID_PSave:
  2991.                                                             useraction=1;
  2992.                                                             a=0;
  2993.                                                             do
  2994.                                                             {
  2995.                                                                 DoMethod(LV_Program,MUIM_List_GetEntry,a,&strptr);
  2996.                                                                 if(strptr)
  2997.                                                                 {
  2998.                                                                     pprog[a]=(strptr[0]-'0')*10+strptr[1]-'0';
  2999.                                                                     a++;
  3000.                                                                 }
  3001.                                                             }while(strptr);
  3002.                                                             pprog[a]=0;
  3003.                                                             set(LV_ProgramSelect,MUIA_List_Quiet,TRUE);
  3004.                                                             DoMethod(LV_ProgramSelect,MUIM_List_Clear);
  3005.                                                             a=0;
  3006.                                                             while(pprog[a])
  3007.                                                             {
  3008.                                                                 DoMethod(LV_TrackSelect,MUIM_List_GetEntry,pprog[a]-1,&strptr);
  3009.                                                                 DoMethod(LV_ProgramSelect,MUIM_List_InsertSingle,strptr,MUIV_List_Insert_Bottom);
  3010.                                                                 a++;
  3011.                                                             }
  3012.                                                             set(LV_ProgramSelect,MUIA_List_Quiet,FALSE);
  3013.                                                         case ID_PRexxSave:
  3014.                                                             sprintf(buff,"%s%s",diskspath,TOCCDID);
  3015.                                                             buff[strlen(diskspath)]='P';
  3016.                                                             buff[strlen(diskspath)+1]='R';
  3017.                                                             if(f=fopen(buff,"w"))
  3018.                                                             {
  3019.                                                                 a=0;
  3020.  
  3021.                                                                 while(pprog[a])
  3022.                                                                     putc(pprog[a++],f);
  3023.  
  3024.                                                                 fclose(f);
  3025.                                                             }
  3026.                                                             set(WI_Program,MUIA_Window_Open,FALSE);
  3027.                                                             break;
  3028.                                                         default:
  3029.                                                             break;
  3030.                                                     }
  3031.                                                     if(vamos)
  3032.                                                     {
  3033.                                                         CDGetPos(TRUE);
  3034.                                                         vamos=FALSE;
  3035.                                                     }
  3036.  
  3037.                                                     if((i || rxmsgs) && signals) signals=Wait(signals|(1<<tmsgport->mp_SigBit));
  3038.                                                 }
  3039.  
  3040.                                                 Wait(1<<tmsgport->mp_SigBit);
  3041.                                                 while(GetMsg(tmsgport));
  3042.                                                 
  3043.                                                 EndARexx();
  3044.                                             }
  3045.                                             else
  3046.                                             {
  3047.                                                 errorstr=glstr(MSG_FailApplication);
  3048.                                             }
  3049. /*
  3050. **                                          if(CL_ProgramList)
  3051. **                                              MUI_DeleteCustomClass(CL_ProgramList);
  3052. */
  3053.                                             FreeMem(TOCbuf,MAX_TOC_LEN);
  3054.                                         }
  3055.                                         else
  3056.                                             errorstr=glstr(MSG_FailMemory);
  3057.  
  3058.                                         FreeMem(scsidata,MAX_DATA_LEN);
  3059.                                     }
  3060.                                     else
  3061.                                         errorstr=glstr(MSG_FailMemory);
  3062.  
  3063.                                     CloseDevice((struct IORequest *)tioreq);
  3064.                                 }
  3065.                                 else
  3066.                                     errorstr=glstr(MSG_FailNoTimer);
  3067.  
  3068.                                 DeleteIORequest(tioreq);
  3069.                             }
  3070.                             else
  3071.                                 errorstr=glstr(MSG_FailNoIO);
  3072.  
  3073.                             DeleteMsgPort(tmsgport);
  3074.                         }
  3075.                         else
  3076.                             errorstr=glstr(MSG_FailNoMP);
  3077.  
  3078.                         FreeMem(scsisense,SENSE_LEN);
  3079.                     }
  3080.                     else
  3081.                         errorstr=glstr(MSG_FailMemory);
  3082.  
  3083.                     FreeMem(scsicmd,sizeof(SCSICMD));
  3084.                 }
  3085.                 else
  3086.                     errorstr=glstr(MSG_FailMemory);
  3087.  
  3088.                 CloseDevice((struct IORequest *)ioreq);
  3089.             }
  3090.             else
  3091.                 errorstr=glstr(MSG_FailNoDevice);
  3092.  
  3093.             DeleteIORequest(ioreq);
  3094.         }
  3095.         else
  3096.             errorstr=glstr(MSG_FailNoIO);
  3097.  
  3098.         DeleteMsgPort(msgport);
  3099.     }
  3100.     else
  3101.         errorstr=glstr(MSG_FailNoMP);
  3102.  
  3103.     if(mydo)
  3104.         FreeDiskObject(mydo);
  3105.  
  3106.     fail(AP_SCDP,errorstr);
  3107.  
  3108.     return 0;
  3109. }
  3110.  
  3111. int DoScsiCmd(UBYTE *data, int datasize, UBYTE *cmd, int cmdsize, UBYTE flags)
  3112. {
  3113.     ioreq->io_Length=sizeof(SCSICMD);
  3114.     ioreq->io_Data=scsicmd;
  3115.     ioreq->io_Command=HD_SCSICMD;
  3116.  
  3117.     scsicmd->scsi_Data=(APTR)data;
  3118.     scsicmd->scsi_Length=datasize;
  3119.     scsicmd->scsi_SenseActual=0;
  3120.     scsicmd->scsi_SenseData=scsisense;
  3121.     scsicmd->scsi_Command=cmd;
  3122.     scsicmd->scsi_CmdLength=cmdsize;
  3123.     scsicmd->scsi_Flags=flags;
  3124.  
  3125.     DoIO((struct IORequest *) ioreq);
  3126.  
  3127.     return ioreq->io_Error;
  3128. }
  3129.  
  3130. void CDEject(void)
  3131. {
  3132.     static SCSICMD6 command=
  3133.     {
  3134.         SCSI_CMD_SSU,
  3135.         0,
  3136.         PAD,
  3137.         PAD,
  3138.         0,
  3139.         PAD,
  3140.     };
  3141.  
  3142.     int err;
  3143.  
  3144.     command.b4=2;   /* I think this number is important: (0=STOP, 1=?, 2=EJECT, 3=LOAD, 4=STOP?)*/
  3145.  
  3146.     if(err=DoScsiCmd(0,0,(UBYTE *)&command,sizeof(command),SCSIF_READ|SCSIF_AUTOSENSE))
  3147.         return;
  3148. }
  3149.  
  3150. void CDLoad(void)
  3151. {
  3152.     static SCSICMD6 command=
  3153.     {
  3154.         SCSI_CMD_SSU,
  3155.         0,
  3156.         PAD,
  3157.         PAD,
  3158.         0,
  3159.         PAD,
  3160.     };
  3161.  
  3162.     int err;
  3163.  
  3164.     command.b4=3;   /* I think this number is important: (0=STOP, 1=?, 2=EJECT, 3=LOAD, 4=STOP?)*/
  3165.  
  3166.     if(err=DoScsiCmd(0,0,(UBYTE *)&command,sizeof(command),SCSIF_READ|SCSIF_AUTOSENSE))
  3167.         return;
  3168. }
  3169.  
  3170. void CDStop(void)
  3171. {
  3172.     static SCSICMD6 command=
  3173.     {
  3174.         SCSI_CMD_SSU,
  3175.         0,
  3176.         PAD,
  3177.         PAD,
  3178.         0,
  3179.         PAD,
  3180.     };
  3181.  
  3182.     int err;
  3183.  
  3184.     command.b4=0;   /* I think this number is important: (0=STOP, 1=?, 2=EJECT, 3=LOAD, 4=STOP?)*/
  3185.  
  3186.     if(status==PLAYING || status==PAUSED)
  3187.         status=STOPPED;
  3188.  
  3189.     userstop=TRUE;
  3190.  
  3191.     if(err=DoScsiCmd(0,0,(UBYTE *)&command,sizeof(command),SCSIF_READ|SCSIF_AUTOSENSE))
  3192.         return;
  3193. }
  3194.  
  3195. void CDGetPos(BOOL settimer)
  3196. {
  3197.     APTR *strptr;
  3198.     char buff[256];
  3199.     BOOL redraw=FALSE;
  3200.  
  3201.     static SCSICMD10 command=
  3202.     {
  3203.         SCSI_CMD_READSUBCHANNEL,
  3204.         0,
  3205.         0x40,
  3206.         0,
  3207.         PAD,
  3208.         PAD,
  3209.         0,
  3210.         0,0,
  3211.         PAD
  3212.     };
  3213.  
  3214.     int err;
  3215.     ULONG microsleft;
  3216.  
  3217.     command.b2=0x40;
  3218.     command.b3=1;
  3219.     command.b6=0;
  3220.     command.b7=255;
  3221.     command.b8=255;
  3222.  
  3223.     if(err=DoScsiCmd((UBYTE *)scsidata, MAX_DATA_LEN, (UBYTE *) &command, sizeof(command),SCSIF_READ|SCSIF_AUTOSENSE))
  3224.     {
  3225.         track=0;
  3226.         status=NODISK;
  3227.         actualindex=totalindex=0;
  3228.         pstatus=NORMAL;
  3229.         if(validTOC)
  3230.         {
  3231.             set(WI_List,MUIA_Window_Open,FALSE);
  3232.             set(WI_Program,MUIA_Window_Open,FALSE);
  3233.             set(BT_List,MUIA_Disabled,TRUE);
  3234.             set(BT_ProgramR,MUIA_Disabled,TRUE);
  3235.             set(BT_ProgramL,MUIA_Selected,FALSE);
  3236.             set(BT_Shuffle,MUIA_Selected,FALSE);
  3237.             set(BT_Repeat,MUIA_Selected,FALSE);
  3238.             set(TX_Track,MUIA_Text_Contents,"--");
  3239.             set(TX_TitleTime,MUIA_Text_Contents,"--:--/--:--");
  3240.             set(TX_CDTime,MUIA_Text_Contents,"--:--/--:--");
  3241.             set(TX_Artist,MUIA_Text_Contents,glstr(MSG_NoDisc));
  3242.             set(TX_Title,MUIA_Text_Contents,"");
  3243.             DoMethod(LV_TrackSelect,MUIM_List_Clear);
  3244.             DoMethod(LV_PList,MUIM_List_Clear);
  3245.             DoMethod(LV_Program,MUIM_List_Clear);
  3246.             DoMethod(LV_ProgramSelect,MUIM_List_Clear);
  3247.             pprog[0]=0;
  3248.             validTOC=0;
  3249.             microsleft=1000000;
  3250.         }
  3251.     }
  3252.     else
  3253.     {
  3254.         /* Now one looks at scsidata[1]. It may be:
  3255.             0x11:   Playing.
  3256.             0x12:   Pause.
  3257.             other:  Stopped.
  3258.  
  3259.            scsidata[6] has the number of the track being played.
  3260.  
  3261.            scsidata[12..15] contains the address which is being played (75ths of second from track start).
  3262.            scsidata[8..11] contains the address from the begin of the CD.
  3263.         */
  3264.         switch(scsidata[1])
  3265.         {
  3266.             case 0x11:
  3267.                 if(status!=PLAYING)
  3268.                 {
  3269.                     status=PLAYING;
  3270.                     redraw=TRUE;
  3271.                 }
  3272.                 if(track!=scsidata[6])
  3273.                 {
  3274.                     track=scsidata[6];
  3275.                     redraw=TRUE;
  3276.                 }
  3277.                 trayout=FALSE;
  3278.                 /* actualindex=(scsidata[12] << 24) | (scsidata[13] << 16) | (scsidata[14] << 8) | (scsidata[15]); */
  3279.                 totalindex=(scsidata[8] << 24) | (scsidata[9] << 16) | (scsidata[10] << 8) | (scsidata[11]);
  3280.                 actualindex=totalindex-TOCaddr[track-1];
  3281.                 microsleft=(75-(actualindex%75))*13333+25;
  3282.                 if(TOCaddr[track]-totalindex<80)
  3283.                 {
  3284.                     microsleft=(TOCaddr[track]-totalindex)*13333;
  3285.                     if(TOCaddr[TOClength]-totalindex<80 && !skip)
  3286.                         actuate=1;
  3287.                 }
  3288.                 if(pstatus!=NORMAL && track>programmed[pactual-1])
  3289.                 {
  3290.                     if(!skip)
  3291.                         actuate=2;
  3292.                     microsleft=1;
  3293.                 }
  3294.                 break;
  3295.             case 0x12:
  3296.                 status=PAUSED;
  3297.                 redraw=TRUE;
  3298.                 track=scsidata[6];
  3299.                 trayout=FALSE;
  3300.                 /* actualindex=(scsidata[12] << 24) | (scsidata[13] << 16) | (scsidata[14] << 8) | (scsidata[15]); */
  3301.                 totalindex=(scsidata[8] << 24) | (scsidata[9] << 16) | (scsidata[10] << 8) | (scsidata[11]);
  3302.                 actualindex=totalindex-TOCaddr[track-1];
  3303.                 microsleft=1000000;
  3304.                 break;
  3305.             default:
  3306.                 status=STOPPED;
  3307.                 redraw=TRUE;
  3308.                 trayout=FALSE;
  3309.                 actualindex=totalindex=0;
  3310.                 track=0;
  3311.                 microsleft=1000000;
  3312.                 if(!userstop && !skip)
  3313.                     actuate=3;
  3314.                 break;
  3315.         }
  3316.  
  3317.         if(!validTOC)
  3318.         {
  3319.             CDReadContents();
  3320.         }
  3321.  
  3322.         if(refresh)
  3323.         {
  3324.             redraw=TRUE;
  3325.             refresh=FALSE;
  3326.         }
  3327.  
  3328.         if(totalindex>=TOCaddr[TOClength])
  3329.         {
  3330.             if(!skip)
  3331.                 actuate=1;
  3332.             track=actualindex=totalindex=0;
  3333.         }
  3334.  
  3335.         if(track>0 && track<=TOClength)
  3336.         {
  3337.             if(pstatus==NORMAL || track==programmed[pactual-1])
  3338.                 set(LV_TrackSelect,MUIA_List_Active,track-1);
  3339.             if(pstatus==PROGRAM)
  3340.             {
  3341.                 if(track==programmed[pactual-1])
  3342.                 {
  3343.                     set(LV_ProgramSelect,MUIA_List_Active,pactual-1);
  3344.                 }
  3345.             }
  3346.             else
  3347.             {
  3348.                 set(LV_ProgramSelect,MUIA_List_Active,MUIV_List_Active_Off);
  3349.             }
  3350.             sprintf(buff,"%02d",track);
  3351.             set(TX_Track,MUIA_Text_Contents,buff);
  3352.             sprintf(buff,"%02.2d:%02.2d/%02.2d:%02.2d",min(actualindex/(60*75),99),(actualindex/75)%60,(TOCaddr[track]-TOCaddr[track-1])/(60*75),((TOCaddr[track]-TOCaddr[track-1])/75)%60 );
  3353.             set(TX_TitleTime,MUIA_Text_Contents,buff);
  3354.             sprintf(buff,"%02.2d:%02.2d/%02.2d:%02.2d",totalindex/(60*75),(totalindex/75)%60,(TOCaddr[TOClength])/(60*75),((TOCaddr[TOClength])/75)%60 );
  3355.             set(TX_CDTime,MUIA_Text_Contents,buff);
  3356.             if(redraw)
  3357.             {
  3358.                 sprintf(buff,"%s - %s",TOCCDartist,TOCCDtitle);
  3359.                 set(TX_Artist,MUIA_Text_Contents,buff);
  3360.                 DoMethod(LV_TrackSelect,MUIM_List_GetEntry,MUIV_List_GetEntry_Active,&strptr);
  3361.                 if(pstatus==NORMAL || track==programmed[pactual-1])
  3362.                     set(TX_Title,MUIA_Text_Contents,((char *)strptr)+4);
  3363.             }
  3364.         }
  3365.         else
  3366.         {
  3367.             if(redraw)
  3368.             {
  3369.                 set(LV_TrackSelect,MUIA_List_Active,MUIV_List_Active_Off);
  3370.                 set(LV_ProgramSelect,MUIA_List_Active,MUIV_List_Active_Off);
  3371.                 sprintf(buff,"--:--/%02.2d:%02.2d",(TOCaddr[TOClength])/(60*75),((TOCaddr[TOClength])/75)%60 );
  3372.                 set(TX_CDTime,MUIA_Text_Contents,buff);
  3373.                 set(TX_Track,MUIA_Text_Contents,"--");
  3374.                 set(TX_TitleTime,MUIA_Text_Contents,"--:--/--:--");
  3375.                 sprintf(buff,"%s - %s",TOCCDartist,TOCCDtitle);
  3376.                 set(TX_Artist,MUIA_Text_Contents,buff);
  3377.                 set(TX_Title,MUIA_Text_Contents,TOCCDtitle);
  3378.             }
  3379.         }
  3380.     }
  3381.     if(settimer)
  3382.     {
  3383.         if(skip)
  3384.             skip--;
  3385.         tioreq->tr_node.io_Command=TR_ADDREQUEST;
  3386.         tioreq->tr_time.tv_secs=microsleft/1000000;
  3387.         tioreq->tr_time.tv_micro=microsleft%1000000;
  3388.         SendIO((struct IORequest *)tioreq);
  3389.     }
  3390. }
  3391.  
  3392.  
  3393. /* THIS FUNCTION IS **NOT** SAFE!!!
  3394. ** I know it somehow works on my system, but I don't know how.
  3395. ** Anyway I leave it here, because I have nothing better. Perhaps I'll
  3396. ** find something better some day.        I DON'T KNOW HOW IT WORKS!!!
  3397. ** It takes a volume between 1 and 31.
  3398. */
  3399. void CDSetVolume(int volume)
  3400. {
  3401.     static SCSICMD6 modecommand;
  3402.     static struct volmodedata
  3403.     {
  3404.         UBYTE head[4];
  3405.         UBYTE page;     /* page code 0x0e */
  3406.         UBYTE plength;  /* page length */
  3407.         UBYTE b2;       /* bit2: Immed, bit 1: SOTC */
  3408.         UBYTE b3;       /* reserved */
  3409.         UBYTE b4;       /* reserved */
  3410.         UBYTE b5;       /* bit 7: APRVal, bit 3-0: format of LBAs / Sec. */
  3411.         UWORD bps;      /* logical blocks per second audio playback */
  3412.         UBYTE out0;     /* lower 4 bits: output port 0 channel selection */
  3413.         UBYTE vol0;     /* output port 0 volume */
  3414.         UBYTE out1;     /* lower 4 bits: output port 1 channel selection */
  3415.         UBYTE vol1;     /* output port 1 volume */
  3416.         UBYTE out2;     /* lower 4 bits: output port 2 channel selection */
  3417.         UBYTE vol2;     /* output port 2 volume */
  3418.         UBYTE out3;     /* lower 4 bits: output port 3 channel selection */
  3419.         UBYTE vol3;     /* output port 3 volume */
  3420.     } modedata;
  3421.     int i,err,j;
  3422.  
  3423.     if(!volumecontrol)
  3424.         return;
  3425.  
  3426.     for(i=0;i<4;i++)
  3427.         modedata.head[i]=0;
  3428.  
  3429.     modecommand.opcode=SCSI_CMD_MSE;
  3430.     modecommand.b1=0;            /* 0 */
  3431.     modecommand.b2=0x0e;         /* 0x0e */
  3432.     modecommand.b3=0;            /* 0 */
  3433.     modecommand.b4=64; /* MAX_DATA_LEN; */
  3434.     modecommand.control=0;
  3435.  
  3436.     if(err=DoScsiCmd((UBYTE *) scsidata, MAX_DATA_LEN, (UBYTE *) &modecommand, sizeof(modecommand), SCSIF_READ|SCSIF_AUTOSENSE))
  3437.         return;
  3438.  
  3439. /*    for(i=0;i<64;i++)
  3440.         printf("%02x",(int)scsidata[i]);
  3441.         printf("\n"); */
  3442.  
  3443.     for (j = (scsidata[0]+1), i = scsidata[3] + 4; i < j; i += scsidata[i+1] + 2)
  3444.         memcpy (&modedata.page, &scsidata[i], 16);
  3445.  
  3446.     modedata.page = 0x0e;
  3447.     modedata.plength = 0x0e;
  3448. /*    modedata.b2=4; */
  3449. /*    modedata.b5=0; */
  3450. /*    modedata.bps=NUM_OF_CDDAFRAMES; (0 en PlayCD)*/
  3451. /*    modedata.out0=1; */
  3452. /*    modedata.out1=2; */
  3453. /*    modedata.out2=0; */
  3454. /*    modedata.out3=0; */
  3455.  
  3456.     if(volume==-1)
  3457.     {
  3458.         volume=(modedata.vol0+modedata.vol1-2)/16;
  3459.         volume=max(1,min(31,volume));
  3460.         set(SL_Volume,MUIA_Slider_Level,volume);
  3461.     }
  3462.  
  3463.     modedata.vol0 = volume*8+1;
  3464.     modedata.vol1 = volume*8+1;
  3465.     modedata.vol2 = volume*8+1;
  3466.     modedata.vol3 = volume*8+1;
  3467.  
  3468.     modecommand.opcode      = SCSI_CMD_MSL;
  3469.     modecommand.b1          = 0x10;                /* 0 antes 0x10 */
  3470.     modecommand.b2          = 0;                   /* 0 */
  3471.     modecommand.b3          = 0;    /* 0x14 */
  3472.     modecommand.b4          = sizeof (modedata);   /* 0 */
  3473.     modecommand.control     = 0;
  3474.  
  3475.     if ((err = DoScsiCmd ((UBYTE *) &modedata, sizeof(modedata),
  3476.                           (UBYTE *) &modecommand, sizeof (modecommand),
  3477.                           (SCSIF_WRITE | SCSIF_AUTOSENSE))) != 0)
  3478.         return;
  3479.  
  3480. }
  3481.  
  3482. void CDPause(void)
  3483. {
  3484.     static SCSICMD10 command =
  3485.     {
  3486.         SCSI_CMD_PAUSERESUME,
  3487.         PAD,
  3488.         0,
  3489.         0,
  3490.         0,
  3491.         0,
  3492.         0,
  3493.         0,
  3494.         0,
  3495.         PAD,
  3496.     };
  3497.  
  3498.     command.b8 = 0x00; /* 0x01 for resuming */
  3499.  
  3500.     DoScsiCmd (NULL, NULL,
  3501.                (UBYTE *) & command, sizeof (command),
  3502.                (SCSIF_READ | SCSIF_AUTOSENSE));
  3503.     if(status==PLAYING)
  3504.         status=PAUSED;
  3505. }
  3506.  
  3507. void CDResume(void)
  3508. {
  3509.     static SCSICMD10 command =
  3510.     {
  3511.         SCSI_CMD_PAUSERESUME,
  3512.         PAD,
  3513.         0,
  3514.         0,
  3515.         0,
  3516.         0,
  3517.         0,
  3518.         0,
  3519.         0,
  3520.         PAD,
  3521.     };
  3522.  
  3523.     command.b8 = 0x01; /* 0x00 for pausing */
  3524.  
  3525.     DoScsiCmd (NULL, NULL,
  3526.                (UBYTE *) & command, sizeof (command),
  3527.                (SCSIF_READ | SCSIF_AUTOSENSE));
  3528. }
  3529.  
  3530. void CDPlay(int start, int length)
  3531. {
  3532.     static SCSICMD12 command =
  3533.     {
  3534.         SCSI_CMD_PLAYAUDIO12,
  3535.         PAD,
  3536.         0, 0, 0, 0,
  3537.         0, 0, 0, 0,
  3538.         PAD,
  3539.         PAD,
  3540.     };
  3541.     command.b2=(start&0xff000000)>>24;
  3542.     command.b3=(start&0x00ff0000)>>16;
  3543.     command.b4=(start&0x0000ff00)>>8;
  3544.     command.b5=(start&0x000000ff);
  3545.  
  3546.     command.b6=(length&0xff000000)>>24;
  3547.     command.b7=(length&0x00ff0000)>>16;
  3548.     command.b8=(length&0x0000ff00)>>8;
  3549.     command.b9=(length&0x000000ff);
  3550.  
  3551.     skip=3;
  3552.  
  3553.     userstop=FALSE;
  3554.     refresh=TRUE;
  3555.  
  3556.     DoScsiCmd((UBYTE *)scsidata,MAX_DATA_LEN,(UBYTE *)&command,sizeof(command),SCSIF_READ|SCSIF_AUTOSENSE);
  3557. }
  3558.  
  3559. void CDReadContents(void)
  3560. {
  3561.     char buff[1024],buff2[256];
  3562.     FILE *f;
  3563.     static SCSICMD10 command=
  3564.     {
  3565.         SCSI_CMD_READTOC,
  3566.         0,
  3567.         PAD,PAD,PAD,PAD,
  3568.         0,
  3569.         0x03,0x24,
  3570.         PAD
  3571.     };
  3572.     int err,TOCsize;
  3573.     UBYTE * TOCptr;
  3574.  
  3575.     validTOC=0;
  3576.  
  3577.     if(err=DoScsiCmd((UBYTE *)TOCbuf,MAX_TOC_LEN,(UBYTE *)&command,sizeof(command),SCSIF_READ|SCSIF_AUTOSENSE))
  3578.         return;
  3579.  
  3580.     TOCsize=(TOCbuf[0]<<8)|TOCbuf[1];
  3581.  
  3582.     TOCaddr[2]=TOCaddr[1]=TOCaddr[0]=0;
  3583.     TOClength=0;
  3584.  
  3585.     if(TOCsize>=2);
  3586.         TOCsize-=2;
  3587.  
  3588.     onevalid=FALSE;
  3589.     for(TOCptr=&TOCbuf[4];TOCptr<(&TOCbuf[4]+TOCsize) && TOClength<100;TOCptr+=8)
  3590.     {
  3591.         TOCaddr[TOClength]=(TOCptr[4]<<24)|(TOCptr[5]<<16)|(TOCptr[6]<<8)|(TOCptr[7]);
  3592.         onevalid|=!((TOCflags[TOClength]=(TOCptr[1]&0x04)>>2)&1);
  3593.         TOClength++;
  3594.     }
  3595.     TOClength--;
  3596.  
  3597.     sprintf(TOCCDID,"ID%02d%06X%06X",TOClength,TOCaddr[2],TOCaddr[TOClength]);
  3598.  
  3599.     set(BT_ProgramL,MUIA_Selected,FALSE);
  3600.     set(BT_Shuffle,MUIA_Selected,FALSE);
  3601.     set(BT_Repeat,MUIA_Selected,FALSE);
  3602.     set(CH_AutoPlay,MUIA_Selected,FALSE);
  3603.     set(CH_AutoProgram,MUIA_Selected,FALSE);
  3604.     set(CH_AutoShuffle,MUIA_Selected,FALSE);
  3605.     set(CH_AutoRepeat,MUIA_Selected,FALSE);
  3606.  
  3607.     useraction=-1;
  3608.  
  3609.     sprintf(buff,"%s%s",diskspath,TOCCDID);
  3610.     if(f=fopen(buff,"r"))
  3611.     {
  3612.         set(LV_TrackSelect,MUIA_List_Quiet,TRUE);
  3613.         set(LV_PList,MUIA_List_Quiet,TRUE);
  3614.         DoMethod(LV_TrackSelect,MUIM_List_Clear);
  3615.         DoMethod(LV_PList,MUIM_List_Clear);
  3616.         fgets(TOCCDartist,128,f);
  3617.         if(TOCCDartist[strlen(TOCCDartist)-1]=='\n')
  3618.             TOCCDartist[strlen(TOCCDartist)-1]='\0';
  3619.         fgets(TOCCDtitle,128,f);
  3620.         if(TOCCDtitle[strlen(TOCCDtitle)-1]=='\n')
  3621.             TOCCDtitle[strlen(TOCCDtitle)-1]='\0';
  3622.         for(err=0;err<TOClength;err++)
  3623.         {
  3624.             fgets(buff,128,f);
  3625.             if(buff[strlen(buff)-1]=='\n')
  3626.                 buff[strlen(buff)-1]='\0';
  3627.             sprintf(buff2,"%02d: %s",err+1,buff);
  3628.             DoMethod(LV_TrackSelect,MUIM_List_InsertSingle,buff2,MUIV_List_Insert_Bottom);
  3629.             DoMethod(LV_PList,MUIM_List_InsertSingle,buff2,MUIV_List_Insert_Bottom);
  3630.         }
  3631.  
  3632.         fgets(buff,128,f);
  3633.         if(*buff=='*')
  3634.         {
  3635.             err=buff[1]&15;
  3636.             if(err&8)
  3637.             {
  3638.                 set(CH_AutoRepeat,MUIA_Selected,TRUE);
  3639.                 if(status==STOPPED)
  3640.                     set(BT_Repeat,MUIA_Selected,TRUE);
  3641.             }
  3642.             if(err&4)
  3643.             {
  3644.                 set(CH_AutoShuffle,MUIA_Selected,TRUE);
  3645.                 if(status==STOPPED)
  3646.                     set(BT_Shuffle,MUIA_Selected,TRUE);
  3647.             }
  3648.             if(err&2)
  3649.             {
  3650.                 set(CH_AutoProgram,MUIA_Selected,TRUE);
  3651.                 if(status==STOPPED)
  3652.                     set(BT_ProgramL,MUIA_Selected,TRUE);
  3653.             }
  3654.             if(err&1)
  3655.             {
  3656.                 set(CH_AutoPlay,MUIA_Selected,TRUE);
  3657.             }
  3658.         }
  3659.  
  3660.         fclose(f);
  3661.         set(LV_TrackSelect,MUIA_List_Quiet,FALSE);
  3662.         set(LV_PList,MUIA_List_Quiet,FALSE);
  3663.     }
  3664.     else
  3665.     {
  3666.         set(LV_TrackSelect,MUIA_List_Quiet,TRUE);
  3667.         set(LV_PList,MUIA_List_Quiet,TRUE);
  3668.         DoMethod(LV_TrackSelect,MUIM_List_Clear);
  3669.         DoMethod(LV_PList,MUIM_List_Clear);
  3670.         strcpy(TOCCDartist,glstr(MSG_UnknownArtist));
  3671.         strcpy(TOCCDtitle,glstr(MSG_UnknownTitle));
  3672.         for(err=0;err<TOClength;err++)
  3673.         {
  3674.             if(TOCflags[err]&1)
  3675.                 sprintf(buff2,glstr(MSG_DataTrack),err+1);
  3676.             else
  3677.                 sprintf(buff2,glstr(MSG_TrackNo),err+1,err+1);
  3678.             DoMethod(LV_TrackSelect,MUIM_List_InsertSingle,buff2,MUIV_List_Insert_Bottom);
  3679.             if(!TOCflags[err])
  3680.                 DoMethod(LV_PList,MUIM_List_InsertSingle,buff2,MUIV_List_Insert_Bottom);
  3681.         }
  3682.         set(LV_TrackSelect,MUIA_List_Quiet,FALSE);
  3683.         set(LV_PList,MUIA_List_Quiet,FALSE);
  3684.     }
  3685.     sprintf(buff,"%s%s",diskspath,TOCCDID);
  3686.     buff[strlen(diskspath)]='P';
  3687.     buff[strlen(diskspath)+1]='R';
  3688.     if(f=fopen(buff,"r"))
  3689.     {
  3690.         int ppp,err;
  3691.  
  3692.         err=0;
  3693.  
  3694.         while((ppp=getc(f))!=EOF)
  3695.             pprog[err++]=(ppp>0 && ppp<=TOClength)?ppp:0;
  3696.  
  3697.         pprog[err]=0;
  3698.  
  3699.         fclose(f);
  3700.  
  3701.         set(LV_ProgramSelect,MUIA_List_Quiet,TRUE);        
  3702.         DoMethod(LV_ProgramSelect,MUIM_List_Clear);
  3703.         err=0;
  3704.         while(pprog[err])
  3705.         {
  3706.             char *strptr;
  3707.             
  3708.             DoMethod(LV_TrackSelect,MUIM_List_GetEntry,pprog[err]-1,&strptr);
  3709.             DoMethod(LV_ProgramSelect,MUIM_List_InsertSingle,strptr,MUIV_List_Insert_Bottom);
  3710.             err++;
  3711.         }
  3712.         set(LV_ProgramSelect,MUIA_List_Quiet,FALSE);
  3713.     }
  3714.     else
  3715.     {
  3716.         pprog[0]=0;
  3717.         DoMethod(LV_ProgramSelect,MUIM_List_Clear);
  3718.     }
  3719.             
  3720.     set(BT_List,MUIA_Disabled,FALSE);
  3721.     set(BT_ProgramR,MUIA_Disabled,FALSE);
  3722.     validTOC=1;
  3723.     
  3724.     if(*scriptoninsert)
  3725.     {
  3726.         LaunchARexxScript(scriptoninsert);
  3727.     }
  3728.     
  3729.     get(CH_AutoPlay,MUIA_Selected,&err);
  3730.     if(err && status==STOPPED)
  3731.     {
  3732.         delayedplay=3;
  3733.     }
  3734.  
  3735.     useraction=-1;
  3736. }
  3737.  
  3738. void DoShuffle(void)
  3739. {
  3740.     int i,j,mx=0,k;
  3741.  
  3742.     programmed[0]=0;
  3743.  
  3744.     if(!onevalid)
  3745.         return;
  3746.  
  3747.     srand(time(NULL));
  3748.  
  3749.     for(i=0;i<TOClength;i++)
  3750.         mx+=!TOCflags[i];
  3751.  
  3752.     for(i=0;i<mx;i++)
  3753.     {
  3754.         programmed[i]=rand()%TOClength;
  3755.         k=TRUE;
  3756.         while(k)
  3757.         {
  3758.             k=TOCflags[programmed[i]];
  3759.  
  3760.             for(j=0;j<i;j++)
  3761.                 k|=(programmed[j]==programmed[i]);
  3762.  
  3763.             if(k)
  3764.             {
  3765.                 programmed[i]++;
  3766.                 programmed[i]%=TOClength;
  3767.             }
  3768.         }
  3769.     }
  3770.     for(i=0;i<mx;i++)
  3771.         programmed[i]++;
  3772.     programmed[mx]=0;
  3773. }
  3774.  
  3775. void DoProgram(void)
  3776. {
  3777.     int i;
  3778.     i=0;
  3779.     while(programmed[i]=pprog[i])
  3780.         i++;
  3781. }
  3782.  
  3783. void FillList(void)
  3784. {
  3785.     int i;
  3786.     UBYTE *strptr;
  3787.  
  3788.     set(ST_Artist,MUIA_String_Contents,TOCCDartist);
  3789.     set(ST_CDTitle,MUIA_String_Contents,TOCCDtitle);
  3790.     set(LV_TitleList,MUIA_List_Quiet,TRUE);
  3791.     DoMethod(LV_TitleList,MUIM_List_Clear);
  3792.     for(i=0;i<TOClength;i++)
  3793.     {
  3794.         DoMethod(LV_TrackSelect,MUIM_List_GetEntry,i,&strptr);
  3795.         DoMethod(LV_TitleList,MUIM_List_InsertSingle,strptr,MUIV_List_Insert_Bottom);
  3796.     }
  3797.     set(LV_TitleList,MUIA_List_Active,0);
  3798.     set(LV_TitleList,MUIA_List_Quiet,FALSE);
  3799.     set(WI_List,MUIA_Window_ActiveObject,ST_Artist);
  3800.     set(WI_List,MUIA_Window_Open,TRUE);
  3801. }
  3802.  
  3803.